@@ -64,8 +64,13 @@ import (
64
64
"sigs.k8s.io/cluster-api/util/predicates"
65
65
)
66
66
67
- // InstanceIDIndex defines the aws machine controller's instance ID index.
68
- const InstanceIDIndex = ".spec.instanceID"
67
+ const (
68
+ // InstanceIDIndex defines the aws machine controller's instance ID index.
69
+ InstanceIDIndex = ".spec.instanceID"
70
+
71
+ // DefaultReconcilerRequeue is the default value for the reconcile retry.
72
+ DefaultReconcilerRequeue = 30 * time .Second
73
+ )
69
74
70
75
// AWSMachineReconciler reconciles a AwsMachine object.
71
76
type AWSMachineReconciler struct {
@@ -532,9 +537,11 @@ func (r *AWSMachineReconciler) reconcileNormal(_ context.Context, machineScope *
532
537
machineScope .Info ("EC2 instance state changed" , "state" , instance .State , "instance-id" , * machineScope .GetInstanceID ())
533
538
}
534
539
540
+ shouldRequeue := false
535
541
switch instance .State {
536
542
case infrav1 .InstanceStatePending :
537
543
machineScope .SetNotReady ()
544
+ shouldRequeue = true
538
545
conditions .MarkFalse (machineScope .AWSMachine , infrav1 .InstanceReadyCondition , infrav1 .InstanceNotReadyReason , clusterv1 .ConditionSeverityWarning , "" )
539
546
case infrav1 .InstanceStateStopping , infrav1 .InstanceStateStopped :
540
547
machineScope .SetNotReady ()
@@ -594,6 +601,10 @@ func (r *AWSMachineReconciler) reconcileNormal(_ context.Context, machineScope *
594
601
}
595
602
596
603
machineScope .Debug ("done reconciling instance" , "instance" , instance )
604
+ if shouldRequeue {
605
+ machineScope .Debug ("but find the instance is pending, requeue" , "instance" , instance .ID )
606
+ return ctrl.Result {RequeueAfter : DefaultReconcilerRequeue }, nil
607
+ }
597
608
return ctrl.Result {}, nil
598
609
}
599
610
0 commit comments