@@ -334,14 +334,6 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope
334
334
return ctrl.Result {}, err
335
335
}
336
336
337
- // Set an error message if we couldn't find the instance.
338
- if instanceStatus == nil {
339
- err = errors .New ("OpenStack instance not found" )
340
- openStackMachine .SetFailure (capierrors .UpdateMachineError , err )
341
- conditions .MarkFalse (openStackMachine , infrav1 .InstanceReadyCondition , infrav1 .InstanceNotFoundReason , clusterv1 .ConditionSeverityError , "" )
342
- return ctrl.Result {}, nil
343
- }
344
-
345
337
// TODO(sbueringer) From CAPA: TODO(ncdc): move this validation logic into a validating webhook (for us: create validation logic in webhook)
346
338
347
339
openStackMachine .Spec .ProviderID = pointer .String (fmt .Sprintf ("openstack:///%s" , instanceStatus .ID ()))
@@ -364,10 +356,14 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope
364
356
conditions .MarkTrue (openStackMachine , infrav1 .InstanceReadyCondition )
365
357
openStackMachine .Status .Ready = true
366
358
case infrav1 .InstanceStateError :
367
- // Error is unexpected, thus we report error and never retry
359
+ // If the machine has a NodeRef then it must have been working at some point,
360
+ // so the error could be something temporary.
361
+ // If not, it is more likely a configuration error so we set failure and never retry.
368
362
scope .Logger ().Info ("Machine instance state is ERROR" , "id" , instanceStatus .ID ())
369
- err = fmt .Errorf ("instance state %q is unexpected" , instanceStatus .State ())
370
- openStackMachine .SetFailure (capierrors .UpdateMachineError , err )
363
+ if machine .Status .NodeRef == nil {
364
+ err = fmt .Errorf ("instance state %q is unexpected" , instanceStatus .State ())
365
+ openStackMachine .SetFailure (capierrors .UpdateMachineError , err )
366
+ }
371
367
conditions .MarkFalse (openStackMachine , infrav1 .InstanceReadyCondition , infrav1 .InstanceStateErrorReason , clusterv1 .ConditionSeverityError , "" )
372
368
return ctrl.Result {}, nil
373
369
case infrav1 .InstanceStateDeleted :
@@ -429,6 +425,8 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope
429
425
func (r * OpenStackMachineReconciler ) getOrCreate (logger logr.Logger , cluster * clusterv1.Cluster , openStackCluster * infrav1.OpenStackCluster , machine * clusterv1.Machine , openStackMachine * infrav1.OpenStackMachine , computeService * compute.Service , userData string ) (* compute.InstanceStatus , error ) {
430
426
instanceStatus , err := computeService .GetInstanceStatusByName (openStackMachine , openStackMachine .Name )
431
427
if err != nil {
428
+ logger .Info ("Unable to get OpenStack instance" , "name" , openStackMachine .Name )
429
+ conditions .MarkFalse (openStackMachine , infrav1 .InstanceReadyCondition , infrav1 .OpenStackErrorReason , clusterv1 .ConditionSeverityError , err .Error ())
432
430
return nil , err
433
431
}
434
432
0 commit comments