Skip to content

Commit 29e5799

Browse files
Merge pull request #1361 from theobarberbany/fix-ms-nil-again
OCPBUGS-55461: Fixes machineset paused condition nil pointer
2 parents f36a937 + c047908 commit 29e5799

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

pkg/controller/machineset/controller.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ func (r *ReconcileMachineSet) Reconcile(ctx context.Context, request reconcile.R
174174
}
175175

176176
if r.gate.Enabled(featuregate.Feature(openshiftfeatures.FeatureGateMachineAPIMigration)) {
177+
machineSetName := machineSet.GetName()
177178
machineSetCopy := machineSet.DeepCopy()
178179
// Check Status.AuthoritativeAPI. If it's not set to MachineAPI. Set the
179180
// paused condition true and return early.
@@ -188,12 +189,15 @@ func (r *ReconcileMachineSet) Reconcile(ctx context.Context, request reconcile.R
188189
"The AuthoritativeAPI is set to %s", string(machineSet.Status.AuthoritativeAPI),
189190
))
190191

191-
machineSet, err := updateMachineSetStatus(r.Client, machineSet, machineSetCopy.Status)
192-
if err != nil {
193-
klog.Errorf("%v: error updating status: %v", machineSetCopy.Name, err)
192+
_, err := updateMachineSetStatus(r.Client, machineSet, machineSetCopy.Status)
193+
if err != nil && !apierrors.IsNotFound(err) {
194+
klog.Errorf("%v: error updating status: %v", machineSetName, err)
195+
return reconcile.Result{}, fmt.Errorf("error updating status: %w", err)
196+
} else if apierrors.IsNotFound(err) {
197+
return reconcile.Result{}, nil
194198
}
195199

196-
klog.Infof("%v: machine set is paused, taking no further action", machineSet.Name)
200+
klog.Infof("%v: machine set is paused, taking no further action", machineSetName)
197201
return reconcile.Result{}, nil
198202
}
199203

@@ -212,11 +216,17 @@ func (r *ReconcileMachineSet) Reconcile(ctx context.Context, request reconcile.R
212216
"%s",
213217
pausedFalseReason,
214218
))
215-
machineSet, err := updateMachineSetStatus(r.Client, machineSet, machineSetCopy.Status)
216-
if err != nil {
217-
klog.Errorf("%v: error updating status: %v", machineSetCopy.Name, err)
219+
220+
var err error
221+
machineSet, err = updateMachineSetStatus(r.Client, machineSet, machineSetCopy.Status)
222+
if err != nil && !apierrors.IsNotFound(err) {
223+
klog.Errorf("%v: error updating status: %v", machineSetName, err)
224+
return reconcile.Result{}, fmt.Errorf("error updating status: %w", err)
225+
} else if apierrors.IsNotFound(err) {
226+
return reconcile.Result{}, nil
218227
}
219-
klog.Infof("%v: setting paused to false and continuing reconcile", machineSet.Name)
228+
229+
klog.Infof("%v: setting paused to false and continuing reconcile", machineSetName)
220230
}
221231

222232
result, err := r.reconcile(ctx, machineSet)

0 commit comments

Comments
 (0)