@@ -64,6 +64,7 @@ type OpenStackMachineReconciler struct {
64
64
65
65
const (
66
66
waitForClusterInfrastructureReadyDuration = 15 * time .Second
67
+ waitForInstanceBecomeActiveToReconcile = 60 * time .Second
67
68
)
68
69
69
70
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=openstackmachines,verbs=get;list;watch;create;update;patch;delete
@@ -343,11 +344,19 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger
343
344
case infrav1 .InstanceStateActive :
344
345
logger .Info ("Machine instance is ACTIVE" , "instance-id" , instanceStatus .ID ())
345
346
openStackMachine .Status .Ready = true
346
- case infrav1 .InstanceStateBuilding :
347
- logger .Info ("Machine instance is BUILDING" , "instance-id" , instanceStatus .ID ())
348
- default :
347
+ case infrav1 .InstanceStateError :
348
+ // Error is unexpected, thus we report error and never retry
349
349
handleUpdateMachineError (logger , openStackMachine , errors .Errorf ("OpenStack instance state %q is unexpected" , instanceStatus .State ()))
350
350
return ctrl.Result {}, nil
351
+ case infrav1 .InstanceStateDeleted :
352
+ // we should avoid further actions for DELETED VM
353
+ logger .Info ("Instance state is DELETED, no actions" )
354
+ return ctrl.Result {}, nil
355
+ default :
356
+ // The other state is normal (for example, migrating, shutoff) but we don't want to proceed until it's ACTIVE
357
+ // due to potential conflict or unexpected actions
358
+ logger .Info ("Waiting for instance to become ACTIVE" , "instance-id" , instanceStatus .ID (), "status" , instanceStatus .State ())
359
+ return ctrl.Result {RequeueAfter : waitForInstanceBecomeActiveToReconcile }, nil
351
360
}
352
361
353
362
if openStackCluster .Spec .ManagedAPIServerLoadBalancer {
0 commit comments