@@ -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 {
@@ -533,9 +538,11 @@ func (r *AWSMachineReconciler) reconcileNormal(_ context.Context, machineScope *
533
538
machineScope .Info ("EC2 instance state changed" , "state" , instance .State , "instance-id" , * machineScope .GetInstanceID ())
534
539
}
535
540
541
+ shouldRequeue := false
536
542
switch instance .State {
537
543
case infrav1 .InstanceStatePending :
538
544
machineScope .SetNotReady ()
545
+ shouldRequeue = true
539
546
conditions .MarkFalse (machineScope .AWSMachine , infrav1 .InstanceReadyCondition , infrav1 .InstanceNotReadyReason , clusterv1 .ConditionSeverityWarning , "" )
540
547
case infrav1 .InstanceStateStopping , infrav1 .InstanceStateStopped :
541
548
machineScope .SetNotReady ()
@@ -595,6 +602,10 @@ func (r *AWSMachineReconciler) reconcileNormal(_ context.Context, machineScope *
595
602
}
596
603
597
604
machineScope .Debug ("done reconciling instance" , "instance" , instance )
605
+ if shouldRequeue {
606
+ machineScope .Debug ("but find the instance is pending, requeue" , "instance" , instance .ID )
607
+ return ctrl.Result {RequeueAfter : DefaultReconcilerRequeue }, nil
608
+ }
598
609
return ctrl.Result {}, nil
599
610
}
600
611
0 commit comments