diff --git a/pkg/cloud/instance.go b/pkg/cloud/instance.go index 4ddb8b96..894390a5 100644 --- a/pkg/cloud/instance.go +++ b/pkg/cloud/instance.go @@ -337,16 +337,17 @@ func (c *client) DeployVM( } // We didn't find a VM so return the original error. - if vm == nil { - return err + if vm != nil { + csMachine.Spec.InstanceID = pointer.String(vm.Id) + csMachine.Status.InstanceState = vm.State } - csMachine.Spec.InstanceID = pointer.String(vm.Id) - csMachine.Status.InstanceState = vm.State - } else { - csMachine.Spec.InstanceID = pointer.String(deployVMResp.Id) - csMachine.Status.Status = pointer.String(metav1.StatusSuccess) + return err } + + csMachine.Spec.InstanceID = pointer.String(deployVMResp.Id) + csMachine.Status.Status = pointer.String(metav1.StatusSuccess) + return nil }