@@ -55,6 +55,7 @@ import (
55
55
"sigs.k8s.io/cluster-api/util/finalizers"
56
56
clog "sigs.k8s.io/cluster-api/util/log"
57
57
"sigs.k8s.io/cluster-api/util/patch"
58
+ "sigs.k8s.io/cluster-api/util/paused"
58
59
"sigs.k8s.io/cluster-api/util/predicates"
59
60
)
60
61
@@ -121,15 +122,13 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt
121
122
c , err := ctrl .NewControllerManagedBy (mgr ).
122
123
For (& clusterv1.Machine {}).
123
124
WithOptions (options ).
124
- WithEventFilter (predicates .ResourceNotPausedAndHasFilterLabel (mgr .GetScheme (), predicateLog , r .WatchFilterValue )).
125
125
Watches (
126
126
& clusterv1.Cluster {},
127
127
handler .EnqueueRequestsFromMapFunc (clusterToMachines ),
128
128
builder .WithPredicates (
129
129
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
130
130
predicates .All (mgr .GetScheme (), predicateLog ,
131
131
predicates .Any (mgr .GetScheme (), predicateLog ,
132
- predicates .ClusterUnpaused (mgr .GetScheme (), predicateLog ),
133
132
predicates .ClusterControlPlaneInitialized (mgr .GetScheme (), predicateLog ),
134
133
),
135
134
predicates .ResourceHasFilterLabel (mgr .GetScheme (), predicateLog , r .WatchFilterValue ),
@@ -195,17 +194,15 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
195
194
m .Spec .ClusterName , m .Name , m .Namespace )
196
195
}
197
196
197
+ if isPaused , conditionChanged , err := paused .EnsurePausedCondition (ctx , r .Client , cluster , m ); err != nil || isPaused || conditionChanged {
198
+ return ctrl.Result {}, err
199
+ }
200
+
198
201
s := & scope {
199
202
cluster : cluster ,
200
203
machine : m ,
201
204
}
202
205
203
- // Return early if the object or Cluster is paused.
204
- if annotations .IsPaused (cluster , m ) {
205
- log .Info ("Reconciliation is paused for this object" )
206
- return ctrl.Result {}, setPausedCondition (ctx , r .Client , s )
207
- }
208
-
209
206
// Initialize the patch helper
210
207
patchHelper , err := patch .NewHelper (m , r .Client )
211
208
if err != nil {
@@ -304,7 +301,6 @@ func patchMachine(ctx context.Context, patchHelper *patch.Helper, machine *clust
304
301
clusterv1 .MachineNodeReadyV1Beta2Condition ,
305
302
clusterv1 .MachineNodeHealthyV1Beta2Condition ,
306
303
clusterv1 .MachineDeletingV1Beta2Condition ,
307
- clusterv1 .MachinePausedV1Beta2Condition ,
308
304
}},
309
305
)
310
306
0 commit comments