@@ -72,6 +72,7 @@ func (c *ReconcileMachineSet) calculateStatus(ms *machinev1.MachineSet, filtered
72
72
73
73
// updateMachineSetStatus attempts to update the Status.Replicas of the given MachineSet, with a single GET/PUT retry.
74
74
func updateMachineSetStatus (c client.Client , ms * machinev1.MachineSet , newStatus machinev1.MachineSetStatus ) (* machinev1.MachineSet , error ) {
75
+ machineSetCopy := ms .DeepCopy ()
75
76
// This is the steady state. It happens when the MachineSet doesn't have any expectations, since
76
77
// we do a periodic relist every 30s. If the generations differ but the replicas are
77
78
// the same, a caller might've resized to the same replica count.
@@ -90,7 +91,7 @@ func updateMachineSetStatus(c client.Client, ms *machinev1.MachineSet, newStatus
90
91
// same status.
91
92
newStatus .ObservedGeneration = ms .Generation
92
93
93
- var getErr , updateErr error
94
+ var getErr , patchErr error
94
95
for i := 0 ; ; i ++ {
95
96
var replicas int32
96
97
if ms .Spec .Replicas != nil {
@@ -105,8 +106,8 @@ func updateMachineSetStatus(c client.Client, ms *machinev1.MachineSet, newStatus
105
106
fmt .Sprintf ("conditions: %v->%v" , ms .Status .Conditions , newStatus .Conditions ))
106
107
107
108
ms .Status = newStatus
108
- updateErr = c .Status ().Update (context .Background (), ms )
109
- if updateErr == nil {
109
+ patchErr = c .Status ().Patch (context .Background (), ms , client . MergeFrom ( machineSetCopy ) )
110
+ if patchErr == nil {
110
111
return ms , nil
111
112
}
112
113
// Stop retrying if we exceed statusUpdateRetries - the machineSet will be requeued with a rate limit.
@@ -121,7 +122,7 @@ func updateMachineSetStatus(c client.Client, ms *machinev1.MachineSet, newStatus
121
122
}
122
123
}
123
124
124
- return nil , updateErr
125
+ return nil , patchErr
125
126
}
126
127
127
128
func (c * ReconcileMachineSet ) getMachineNode (machine * machinev1.Machine ) (* corev1.Node , error ) {
0 commit comments