@@ -493,25 +493,27 @@ func (c *controller) reconcileClusterMachineSet(key string) error {
493493 return err
494494 }
495495
496- if machineSet .DeletionTimestamp != nil {
497- if finalizers := sets .NewString (machineSet .Finalizers ... ); ! finalizers .Has (DeleteFinalizerName ) {
498- return nil
499- }
500- if len (filteredMachines ) == 0 {
501- c .deleteMachineSetFinalizers (machineSet )
502- return nil
503- }
504- glog .V (4 ).Infof ("Deleting all child machines as MachineSet %s has set deletionTimestamp" , machineSet .Name )
505- c .terminateMachines (filteredMachines , machineSet )
506- return nil
507- }
508-
509496 machineSetNeedsSync := c .expectations .SatisfiedExpectations (key )
510497 var manageReplicasErr error
511- if machineSetNeedsSync {
498+
499+ if machineSetNeedsSync && machineSet .DeletionTimestamp == nil {
500+ // manageReplicas is the core machineSet method where scale up/down occurs
501+ // It is not called when deletion timestamp is set
512502 manageReplicasErr = c .manageReplicas (filteredMachines , machineSet )
503+
504+ } else if machineSet .DeletionTimestamp != nil {
505+ // When machineSet if triggered for deletion
506+
507+ if len (filteredMachines ) == 0 {
508+ // If machines backing a machineSet are zero,
509+ // remove the machineSetFinalizer
510+ c .deleteMachineSetFinalizers (machineSet )
511+ } else if finalizers := sets .NewString (machineSet .Finalizers ... ); finalizers .Has (DeleteFinalizerName ) {
512+ // Trigger deletion of machines backing the machineSet
513+ glog .V (4 ).Infof ("Deleting all child machines as MachineSet %s has set deletionTimestamp" , machineSet .Name )
514+ c .terminateMachines (filteredMachines , machineSet )
515+ }
513516 }
514- //glog.V(2).Infof("Print manageReplicasErr: %v ",manageReplicasErr) //Remove
515517
516518 machineSet = machineSet .DeepCopy ()
517519 newStatus := calculateMachineSetStatus (machineSet , filteredMachines , manageReplicasErr )
@@ -521,7 +523,9 @@ func (c *controller) reconcileClusterMachineSet(key string) error {
521523 if err != nil {
522524 // Multiple things could lead to this update failing. Requeuing the machine set ensures
523525 // Returning an error causes a requeue without forcing a hotloop
524- glog .V (2 ).Infof ("update machine failed with: %v" , err ) //Remove
526+ if ! apierrors .IsNotFound (err ) {
527+ glog .Errorf ("Update machineSet %s failed with: %s" , machineSet .Name , err )
528+ }
525529 return err
526530 }
527531
0 commit comments