Skip to content

Commit 604421c

Browse files
committed
clear failure reason/message, improve logging
1 parent 5f218e7 commit 604421c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

exp/controllers/azuremachinepoolmachine_controller.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,17 @@ func (ampmr *AzureMachinePoolMachineController) reconcileNormal(ctx context.Cont
294294
ampmr.Recorder.Eventf(machineScope.AzureMachinePoolMachine, corev1.EventTypeWarning, "FailedVMState", "Azure scale set VM is in failed state")
295295
machineScope.SetFailureReason(capierrors.UpdateMachineError)
296296
machineScope.SetFailureMessage(errors.Errorf("Azure VM state is %s", state))
297+
case infrav1.Succeeded:
298+
ampmr.Recorder.Eventf(machineScope.AzureMachinePoolMachine, corev1.EventTypeNormal, "ProvisioningSucceeded", "Azure scale set VM is in succeeded state")
299+
// clear failure reason/message in case it was there
300+
// TODO(mw): not sure if this works, we also need to probably clear the failure reason/message in another way.
301+
if machineScope.AzureMachinePoolMachine.Status.FailureReason != nil {
302+
machineScope.SetFailureReason(capierrors.MachineStatusError(""))
303+
machineScope.SetFailureMessage(errors.New(""))
304+
}
297305
case infrav1.Deleting:
298-
log.V(4).Info("deleting machine because state is Deleting", "machine", machineScope.Name())
306+
ampmr.Recorder.Eventf(machineScope.AzureMachinePoolMachine, corev1.EventTypeNormal, "Deleting", "Azure scale set VM is in deleting state")
307+
log.V(2).Info("deleting machine because state is Deleting", "machine", machineScope.Name())
299308
if err := ampmr.Client.Delete(ctx, machineScope.Machine); err != nil {
300309
return reconcile.Result{}, errors.Wrap(err, "machine failed to be deleted when deleting")
301310
}

0 commit comments

Comments
 (0)