@@ -59,9 +59,9 @@ import (
59
59
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/ssm"
60
60
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/userdata"
61
61
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger"
62
+ "sigs.k8s.io/cluster-api-provider-aws/v2/util/paused"
62
63
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
63
64
"sigs.k8s.io/cluster-api/util"
64
- "sigs.k8s.io/cluster-api/util/annotations"
65
65
"sigs.k8s.io/cluster-api/util/conditions"
66
66
"sigs.k8s.io/cluster-api/util/predicates"
67
67
)
@@ -183,11 +183,6 @@ func (r *AWSMachineReconciler) Reconcile(ctx context.Context, req ctrl.Request)
183
183
return ctrl.Result {}, nil
184
184
}
185
185
186
- if annotations .IsPaused (cluster , awsMachine ) {
187
- log .Info ("AWSMachine or linked Cluster is marked as paused. Won't reconcile" )
188
- return ctrl.Result {}, nil
189
- }
190
-
191
186
log = log .WithValues ("cluster" , klog .KObj (cluster ))
192
187
193
188
infraCluster , err := r .getInfraCluster (ctx , log , cluster , awsMachine )
@@ -201,6 +196,10 @@ func (r *AWSMachineReconciler) Reconcile(ctx context.Context, req ctrl.Request)
201
196
202
197
infrav1 .SetDefaults_AWSMachineSpec (& awsMachine .Spec )
203
198
199
+ if isPaused , conditionChanged , err := paused .EnsurePausedCondition (ctx , r .Client , cluster , awsMachine ); err != nil || isPaused || conditionChanged {
200
+ return ctrl.Result {}, err
201
+ }
202
+
204
203
// Create the machine scope
205
204
machineScope , err := scope .NewMachineScope (scope.MachineScopeParams {
206
205
Client : r .Client ,
@@ -254,7 +253,7 @@ func (r *AWSMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
254
253
& infrav1.AWSCluster {},
255
254
handler .EnqueueRequestsFromMapFunc (AWSClusterToAWSMachines ),
256
255
).
257
- WithEventFilter (predicates .ResourceNotPausedAndHasFilterLabel (mgr .GetScheme (), log .GetLogger (), r .WatchFilterValue )).
256
+ WithEventFilter (predicates .ResourceHasFilterLabel (mgr .GetScheme (), log .GetLogger (), r .WatchFilterValue )).
258
257
WithEventFilter (
259
258
predicate.Funcs {
260
259
// Avoid reconciling if the event triggering the reconciliation is related to incremental status updates
0 commit comments