Skip to content

Commit 836ccea

Browse files
authored
Merge pull request #94 from aws/fix-vm-instance-id-nil
Check VM instance ID is nil when deleting CS machine
2 parents 4087a2b + 03de2c3 commit 836ccea

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

controllers/cloudstackmachine_controller.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ func (r *CloudStackMachineReconciliationRunner) GetOrCreateMachineStateChecker()
249249
}
250250

251251
func (r *CloudStackMachineReconciliationRunner) ReconcileDelete() (retRes ctrl.Result, reterr error) {
252+
if r.ReconciliationSubject.Spec.InstanceID == nil {
253+
r.Log.Info("VM Instance ID is nil")
254+
return ctrl.Result{}, nil
255+
}
252256
r.Log.Info("Deleting instance", "instance-id", r.ReconciliationSubject.Spec.InstanceID)
253257
// Use CSClient instead of CSUser here to expunge as admin.
254258
// The CloudStack-Go API does not return an error, but the VM won't delete with Expunge set if requested by
@@ -260,7 +264,7 @@ func (r *CloudStackMachineReconciliationRunner) ReconcileDelete() (retRes ctrl.R
260264
}
261265
return ctrl.Result{}, err
262266
}
263-
r.Log.Info("VM Deleted.")
267+
r.Log.Info("VM Deleted")
264268
controllerutil.RemoveFinalizer(r.ReconciliationSubject, infrav1.MachineFinalizer)
265269
return ctrl.Result{}, nil
266270
}

0 commit comments

Comments
 (0)