[vSphere] Add check for nil motask
@@ -68,6 +68,8 @@ func (r *Reconciler) create() error {
return err
}
}
+
+ if moTask != nil {
if moTask.Info.State == types.TaskInfoStateError {
metrics.RegisterFailedInstanceCreate(&metrics.MachineLabels{
Name: r.machine.Name,
@@ -82,6 +84,7 @@ func (r *Reconciler) create() error {
return err
}
}
+ }
if _, err := findVM(r.machineScope); err != nil {
if !isNotFound(err) {
@@ -121,6 +124,7 @@ func (r *Reconciler) update() error {
return err
}
}
+ if motask != nil {
if motask.Info.State == types.TaskInfoStateError {
metrics.RegisterFailedInstanceCreate(&metrics.MachineLabels{
Name: r.machine.Name,
@@ -135,6 +139,7 @@ func (r *Reconciler) update() error {
return err
}
}
+ }
vmRef, err := findVM(r.machineScope)
if err != nil {
@@ -182,6 +187,7 @@ func (r *Reconciler) delete() error {
return err
}
}
+ if moTask != nil {
if moTask.Info.State == types.TaskInfoStateError {
metrics.RegisterFailedInstanceCreate(&metrics.MachineLabels{
Name: r.machine.Name,
@@ -196,6 +202,7 @@ func (r *Reconciler) delete() error {
return err
}
}
+ }
vmRef, err := findVM(r.machineScope)
if err != nil {
