Skip to content

Commit

Permalink
Check VM instance ID is nil when deleting CS machine
Browse files Browse the repository at this point in the history
  • Loading branch information
wongni committed May 17, 2022
1 parent 4087a2b commit 03de2c3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion controllers/cloudstackmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ func (r *CloudStackMachineReconciliationRunner) GetOrCreateMachineStateChecker()
}

func (r *CloudStackMachineReconciliationRunner) ReconcileDelete() (retRes ctrl.Result, reterr error) {
if r.ReconciliationSubject.Spec.InstanceID == nil {
r.Log.Info("VM Instance ID is nil")
return ctrl.Result{}, nil
}
r.Log.Info("Deleting instance", "instance-id", r.ReconciliationSubject.Spec.InstanceID)
// Use CSClient instead of CSUser here to expunge as admin.
// The CloudStack-Go API does not return an error, but the VM won't delete with Expunge set if requested by
Expand All @@ -260,7 +264,7 @@ func (r *CloudStackMachineReconciliationRunner) ReconcileDelete() (retRes ctrl.R
}
return ctrl.Result{}, err
}
r.Log.Info("VM Deleted.")
r.Log.Info("VM Deleted")
controllerutil.RemoveFinalizer(r.ReconciliationSubject, infrav1.MachineFinalizer)
return ctrl.Result{}, nil
}
Expand Down

0 comments on commit 03de2c3

Please sign in to comment.