Skip to content

Commit

Permalink
Fix Machine status if infra/bootstrap obj deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
kashifest committed Sep 27, 2019
1 parent 0ded052 commit 29f3724
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controllers/machine_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ func (r *MachineReconciler) reconcileExternal(ctx context.Context, m *clusterv1.
obj, err := external.Get(r.Client, ref, m.Namespace)
if err != nil {
if apierrors.IsNotFound(err) {
if m.Status.InfrastructureReady {
// Infra object went missing after the machine was up and running
r.Log.Error(err, "Infrastructure or bootstrap object went missing. Updating Machine Status")
machineStatusError := capierrors.MachineStatusError("InvalidConfiguration")
m.Status.ErrorReason = &machineStatusError
m.Status.ErrorMessage = pointer.StringPtr(fmt.Sprintf("Failure detected from referenced resource %v with name %q",
ref.GroupVersionKind(), ref.Name))
}
return nil, errors.Wrapf(&capierrors.RequeueAfterError{RequeueAfter: externalReadyWait},
"could not find %v %q for Machine %q in namespace %q, requeuing",
ref.GroupVersionKind(), ref.Name, m.Name, m.Namespace)
Expand Down

0 comments on commit 29f3724

Please sign in to comment.