Skip to content

Commit

Permalink
[Fix] Update the failure setting logic in Linode Machine Controller (#…
Browse files Browse the repository at this point in the history
…543)

* Just set the faliure if the err code is 400

---------

Co-authored-by: Khaja Omer <[email protected]>
  • Loading branch information
komer3 and Khaja Omer authored Oct 16, 2024
1 parent 90e9677 commit 2c91eb4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions controller/linodemachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,14 @@ func (r *LinodeMachineReconciler) reconcile(ctx context.Context, logger logr.Log
//nolint:dupl // Code duplication is simplicity in this case.
defer func() {
if err != nil {
machineScope.LinodeMachine.Status.FailureReason = util.Pointer(failureReason)
machineScope.LinodeMachine.Status.FailureMessage = util.Pointer(err.Error())

conditions.MarkFalse(machineScope.LinodeMachine, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, "%s", err.Error())
// Only set failure reason if the error is not retryable.
if linodego.ErrHasStatus(err, http.StatusBadRequest) {
machineScope.LinodeMachine.Status.FailureReason = util.Pointer(failureReason)
machineScope.LinodeMachine.Status.FailureMessage = util.Pointer(err.Error())
conditions.MarkFalse(machineScope.LinodeMachine, clusterv1.ReadyCondition, string(failureReason), clusterv1.ConditionSeverityError, "%s", err.Error())
}

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

Expand Down

0 comments on commit 2c91eb4

Please sign in to comment.