Skip to content

Commit

Permalink
Merge pull request #94 from aws/fix-vm-instance-id-nil
Browse files Browse the repository at this point in the history
Check VM instance ID is nil when deleting CS machine
  • Loading branch information
wongni authored May 17, 2022
2 parents 4087a2b + 03de2c3 commit 836ccea
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 836ccea

Please sign in to comment.