Wake up when new migrations can be started
@@ -319,11 +319,6 @@ func (c *EvacuationController) sync(node *k8sv1.Node, vmisOnNode []*virtv1.Virtu
return nil
}
- if len(activeMigrations) >= 5 {
- // Don't overload the cluster with migrations
- return nil
- }
-
now := time.Now()
notMigratingVMIs := c.filterRunningNonMigratingVMIs(vmisOnNode, activeMigrations)
@@ -340,6 +335,20 @@ func (c *EvacuationController) sync(node *k8sv1.Node, vmisOnNode []*virtv1.Virtu
}
}
+ if len(migrationCandidates) == 0 {
+ // nothing to do
+ return nil
+ }
+
+ if len(activeMigrations) >= 5 {
+ // Don't create hundreds of pending migration objects.
+ // This is just best-effort and is *not* intended to not overload the cluster
+ // The migration controller needs to limit itself to a reasonable number
+ // We have to re-enqueue since migrations from other controllers or workers` don't wake us up again
+ c.Queue.AddAfter(node.Name, 5*time.Second)
+ return nil
+ }
+
diff := int(math.Min(float64(5-len(activeMigrations)), float64(len(migrationCandidates))))
if diff == 0 {
