Skip to content

Commit

Permalink
Update azuremachine_controller.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Cecile Robert-Michon committed Mar 15, 2021
1 parent ea39446 commit 0366cd4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions controllers/azuremachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,11 @@ func (r *AzureMachineReconciler) reconcileNormal(ctx context.Context, machineSco
return reconcile.Result{}, errors.Wrap(err, "failed to reconcile AzureMachine")
}

r.Recorder.Eventf(machineScope.AzureMachine, corev1.EventTypeWarning, "ReconcileError", errors.Wrapf(err, "failed to reconcile AzureMachine").Error())
conditions.MarkFalse(machineScope.AzureMachine, infrav1.VMRunningCondition, infrav1.VMProvisionFailedReason, clusterv1.ConditionSeverityError, err.Error())

// Handle transient and terminal errors
var reconcileError azure.ReconcileError
if errors.As(err, &reconcileError) {
if reconcileError.IsTerminal() {
r.Recorder.Eventf(machineScope.AzureMachine, corev1.EventTypeWarning, "ReconcileError", errors.Wrapf(err, "failed to reconcile AzureMachine").Error())
machineScope.Error(err, "failed to reconcile AzureMachine", "name", machineScope.Name())
machineScope.SetFailureReason(capierrors.CreateMachineError)
machineScope.SetFailureMessage(err)
Expand All @@ -309,10 +307,12 @@ func (r *AzureMachineReconciler) reconcileNormal(ctx context.Context, machineSco
}

if reconcileError.IsTransient() {
machineScope.Error(err, "failed to reconcile AzureMachine", "name", machineScope.Name())
machineScope.Error(err, "transient failure to reconcile AzureMachine, retrying", "name", machineScope.Name())
return reconcile.Result{RequeueAfter: reconcileError.RequeueAfter()}, nil
}
}
r.Recorder.Eventf(machineScope.AzureMachine, corev1.EventTypeWarning, "ReconcileError", errors.Wrapf(err, "failed to reconcile AzureMachine").Error())
conditions.MarkFalse(machineScope.AzureMachine, infrav1.VMRunningCondition, infrav1.VMProvisionFailedReason, clusterv1.ConditionSeverityError, err.Error())
return reconcile.Result{}, errors.Wrap(err, "failed to reconcile AzureMachine")
}

Expand Down

0 comments on commit 0366cd4

Please sign in to comment.