@@ -58,7 +58,7 @@ func (c *controller) addMachine(obj interface{}) {
5858 glog .Errorf ("Couldn't get key for object %+v: %v" , obj , err )
5959 return
6060 }
61- glog .V (4 ).Info ( "Adding machine object" )
61+ glog .V (4 ).Infof ( "Add/Update/Delete machine object %q" , key )
6262 c .machineQueue .Add (key )
6363}
6464
@@ -184,7 +184,7 @@ func (c *controller) reconcileClusterMachine(machine *v1alpha1.Machine) error {
184184 }
185185 }
186186
187- c .enqueueMachineAfter (machine , time .Minute * 10 )
187+ c .enqueueMachineAfter (machine , 10 * time .Minute )
188188 return nil
189189}
190190
@@ -207,6 +207,7 @@ func (c *controller) addNodeToMachine(obj interface{}) {
207207 return
208208 }
209209
210+ glog .V (4 ).Infof ("Add machine object backing node %q" , machine .Name )
210211 c .enqueueMachine (machine )
211212}
212213
@@ -545,8 +546,9 @@ func (c *controller) updateMachineStatus(
545546func (c * controller ) updateMachineConditions (machine * v1alpha1.Machine , conditions []v1.NodeCondition ) (* v1alpha1.Machine , error ) {
546547
547548 var (
548- msg string
549- lastOperationType v1alpha1.MachineOperationType
549+ msg string
550+ lastOperationType v1alpha1.MachineOperationType
551+ objectRequiresUpdate bool
550552 )
551553
552554 // Get the latest version of the machine so that we can avoid conflicts
@@ -556,12 +558,14 @@ func (c *controller) updateMachineConditions(machine *v1alpha1.Machine, conditio
556558 }
557559
558560 clone := machine .DeepCopy ()
559- clone .Status .Conditions = conditions
560561
561- //glog.Info(c.isHealthy(clone))
562+ if nodeConditionsHaveChanged (clone .Status .Conditions , conditions ) {
563+ clone .Status .Conditions = conditions
564+ objectRequiresUpdate = true
565+ }
562566
563567 if clone .Status .CurrentStatus .Phase == v1alpha1 .MachineTerminating {
564- // If machine is already in terminating state, don't update
568+ // If machine is already in terminating state, don't update health status
565569
566570 } else if ! c .isHealthy (clone ) && clone .Status .CurrentStatus .Phase == v1alpha1 .MachineRunning {
567571 // If machine is not healthy, and current state is running,
@@ -580,6 +584,7 @@ func (c *controller) updateMachineConditions(machine *v1alpha1.Machine, conditio
580584 Type : v1alpha1 .MachineOperationHealthCheck ,
581585 LastUpdateTime : metav1 .Now (),
582586 }
587+ objectRequiresUpdate = true
583588
584589 } else if c .isHealthy (clone ) && clone .Status .CurrentStatus .Phase != v1alpha1 .MachineRunning {
585590 // If machine is healhy and current machinePhase is not running.
@@ -609,16 +614,22 @@ func (c *controller) updateMachineConditions(machine *v1alpha1.Machine, conditio
609614 TimeoutActive : false ,
610615 LastUpdateTime : metav1 .Now (),
611616 }
617+ objectRequiresUpdate = true
618+
612619 }
613620
614- clone , err = c .controlMachineClient .Machines (clone .Namespace ).Update (clone )
615- if err != nil {
616- // Keep retrying until update goes through
617- glog .V (2 ).Infof ("Warning: Updated failed, retrying, error: %q" , err )
618- return c .updateMachineConditions (machine , conditions )
621+ if objectRequiresUpdate {
622+ clone , err = c .controlMachineClient .Machines (clone .Namespace ).Update (clone )
623+ if err != nil {
624+ // Keep retrying until update goes through
625+ glog .Warningf ("Updated failed, retrying, error: %q" , err )
626+ return c .updateMachineConditions (machine , conditions )
627+ }
628+
629+ return clone , nil
619630 }
620631
621- return clone , nil
632+ return machine , nil
622633}
623634
624635func (c * controller ) updateMachineFinalizers (machine * v1alpha1.Machine , finalizers []string ) {
@@ -715,7 +726,7 @@ func (c *controller) checkMachineTimeout(machine *v1alpha1.Machine) {
715726 // Timeout value obtained by subtracting last operation with expected time out period
716727 timeOut := metav1 .Now ().Add (- timeOutDuration ).Sub (machine .Status .CurrentStatus .LastUpdateTime .Time )
717728 if timeOut > 0 {
718- // If machine health timeout occurs while joining or rejoining of machine
729+ // Machine health timeout occurs while joining or rejoining of machine
719730
720731 if machine .Status .CurrentStatus .Phase == v1alpha1 .MachinePending {
721732 // Timeout occurred while machine creation
@@ -748,20 +759,14 @@ func (c *controller) checkMachineTimeout(machine *v1alpha1.Machine) {
748759 // Log the error message for machine failure
749760 glog .Error (description )
750761
762+ // Update the machine status to reflect the changes
763+ c .updateMachineStatus (machine , lastOperation , currentStatus )
764+
751765 } else {
752766 // If timeout has not occurred, re-enqueue the machine
753767 // after a specified sleep time
754768 c .enqueueMachineAfter (machine , sleepTime )
755- currentStatus = v1alpha1.CurrentStatus {
756- Phase : machine .Status .CurrentStatus .Phase ,
757- TimeoutActive : true ,
758- LastUpdateTime : machine .Status .CurrentStatus .LastUpdateTime ,
759- }
760- lastOperation = machine .Status .LastOperation
761769 }
762-
763- // Update the machine status to reflect the changes
764- c .updateMachineStatus (machine , lastOperation , currentStatus )
765770 }
766771}
767772
0 commit comments