Skip to content

Commit 2c91eb4

Browse files
authored
[Fix] Update the failure setting logic in Linode Machine Controller (#543)
* Just set the faliure if the err code is 400 --------- Co-authored-by: Khaja Omer <[email protected]>
1 parent 90e9677 commit 2c91eb4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

controller/linodemachine_controller.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,14 @@ func (r *LinodeMachineReconciler) reconcile(ctx context.Context, logger logr.Log
174174
//nolint:dupl // Code duplication is simplicity in this case.
175175
defer func() {
176176
if err != nil {
177-
machineScope.LinodeMachine.Status.FailureReason = util.Pointer(failureReason)
178-
machineScope.LinodeMachine.Status.FailureMessage = util.Pointer(err.Error())
179-
180-
conditions.MarkFalse(machineScope.LinodeMachine, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, "%s", err.Error())
177+
// Only set failure reason if the error is not retryable.
178+
if linodego.ErrHasStatus(err, http.StatusBadRequest) {
179+
machineScope.LinodeMachine.Status.FailureReason = util.Pointer(failureReason)
180+
machineScope.LinodeMachine.Status.FailureMessage = util.Pointer(err.Error())
181+
conditions.MarkFalse(machineScope.LinodeMachine, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, "%s", err.Error())
182+
}
181183

184+
// Record the event regardless of whether the error is retryable or not for visibility.
182185
r.Recorder.Event(machineScope.LinodeMachine, corev1.EventTypeWarning, string(failureReason), err.Error())
183186
}
184187

0 commit comments

Comments
 (0)