Skip to content

Commit c411423

Browse files
authored
reconcileClusterMachineTermination should return nil if explicit enqueue is done and reconcileClusterMachineClass() should avoid redundant processing of machines (#1056)
1 parent 8f7eb07 commit c411423

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

pkg/util/provider/machinecontroller/machine.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (c *controller) reconcileClusterMachineTermination(key string) error {
277277
if err != nil {
278278
klog.Errorf("cannot reconcile machine %q: %s", machine.Name, err)
279279
c.enqueueMachineTerminationAfter(machine, time.Duration(retry), err.Error())
280-
return err
280+
return nil
281281
}
282282

283283
// Process a delete event
@@ -292,15 +292,14 @@ func (c *controller) reconcileClusterMachineTermination(key string) error {
292292

293293
if err != nil {
294294
c.enqueueMachineTerminationAfter(machine, time.Duration(retryPeriod), err.Error())
295-
return err
296295
} else {
297296
// If the informer loses connection to the API server it may need to resync.
298297
// If a resource is deleted while the watch is down, the informer won’t get
299298
// delete event because the object is already gone. To avoid this edge-case,
300299
// a requeue is scheduled post machine deletion as well.
301300
c.enqueueMachineTerminationAfter(machine, time.Duration(retryPeriod), "post-deletion reconcile")
302-
return nil
303301
}
302+
return nil
304303
}
305304

306305
/*

pkg/util/provider/machinecontroller/machineclass.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (c *controller) reconcileClusterMachineClassKey(key string) error {
8888
c.enqueueMachineClassAfter(class, time.Duration(machineutils.ShortRetry))
8989
} else {
9090
// Re-enqueue periodically to avoid missing of events
91-
// TODO: Get ride of this logic
91+
// TODO: Get rid of this logic
9292
c.enqueueMachineClassAfter(class, time.Duration(machineutils.LongRetry))
9393
}
9494

@@ -131,19 +131,18 @@ func (c *controller) reconcileClusterMachineClass(ctx context.Context, class *v1
131131
}
132132

133133
for _, m := range machines {
134-
c.enqueueMachine(m, reason)
134+
// Enqueue only the non-terminating machines to support changes to virtual capacity to nodes.
135+
// Changes to virtual capacity need not be reflected on terminating machines as they are being deleted.
136+
if m.DeletionTimestamp == nil {
137+
c.enqueueMachine(m, reason)
138+
}
135139
}
136140
return nil
137141
}
138142

139143
if len(machines) > 0 {
140144
// Machines are still referring the machine class, please wait before deletion
141145
klog.V(3).Infof("Cannot remove finalizer on %s because still (%d) machines are referencing it", class.Name, len(machines))
142-
143-
for _, machine := range machines {
144-
c.addMachine(machine)
145-
}
146-
147146
return fmt.Errorf("Retry as machine objects are still referring the machineclass")
148147
}
149148

0 commit comments

Comments
 (0)