@@ -776,17 +776,22 @@ func (r *OpenStackMachineReconciler) getOrCreateInstance(logger logr.Logger, ope
776
776
}
777
777
if instanceStatus == nil {
778
778
// Check if there is an existing instance with machine name, in case where instance ID would not have been stored in machine status
779
- if instanceStatus , err = computeService .GetInstanceStatusByName (openStackMachine , openStackMachine .Name ); err == nil {
780
- if instanceStatus != nil {
781
- return instanceStatus , nil
782
- }
783
- if openStackMachine .Status .InstanceID != nil {
784
- logger .Info ("Not reconciling machine in failed state. The previously existing OpenStack instance is no longer available" )
785
- conditions .MarkFalse (openStackMachine , infrav1 .InstanceReadyCondition , infrav1 .InstanceNotFoundReason , clusterv1 .ConditionSeverityError , "virtual machine no longer exists" )
786
- openStackMachine .SetFailure (capierrors .UpdateMachineError , errors .New ("virtual machine no longer exists" ))
787
- return nil , nil
788
- }
779
+ instanceStatus , err = computeService .GetInstanceStatusByName (openStackMachine , openStackMachine .Name )
780
+ if err != nil {
781
+ logger .Info ("Unable to get OpenStack instance by name" , "name" , openStackMachine .Name )
782
+ conditions .MarkFalse (openStackMachine , infrav1 .InstanceReadyCondition , infrav1 .InstanceCreateFailedReason , clusterv1 .ConditionSeverityError , err .Error ())
783
+ return nil , err
784
+ }
785
+ if instanceStatus != nil {
786
+ return instanceStatus , nil
789
787
}
788
+ if openStackMachine .Status .InstanceID != nil {
789
+ logger .Info ("Not reconciling machine in failed state. The previously existing OpenStack instance is no longer available" )
790
+ conditions .MarkFalse (openStackMachine , infrav1 .InstanceReadyCondition , infrav1 .InstanceNotFoundReason , clusterv1 .ConditionSeverityError , "virtual machine no longer exists" )
791
+ openStackMachine .SetFailure (capierrors .UpdateMachineError , errors .New ("virtual machine no longer exists" ))
792
+ return nil , nil
793
+ }
794
+
790
795
instanceSpec , err := machineToInstanceSpec (openStackCluster , machine , openStackMachine , userData )
791
796
if err != nil {
792
797
return nil , err
0 commit comments