Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaja Omer committed Oct 16, 2024
1 parent c5c0b45 commit 15cc858
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions controller/linodemachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,15 @@ func (r *LinodeMachineReconciler) reconcile(ctx context.Context, logger logr.Log
failureReason := cerrs.MachineStatusError("UnknownError")
//nolint:dupl // Code duplication is simplicity in this case.
defer func() {
if err != nil && !util.IsRetryableError(err) {
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())
if err != nil {
// Only set failure reason if the error is not retryable.
if !util.IsRetryableError(err) {
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 15cc858

Please sign in to comment.