@@ -60,6 +60,7 @@ import (
60
60
"sigs.k8s.io/cluster-api/util/labels/format"
61
61
clog "sigs.k8s.io/cluster-api/util/log"
62
62
"sigs.k8s.io/cluster-api/util/patch"
63
+ "sigs.k8s.io/cluster-api/util/paused"
63
64
"sigs.k8s.io/cluster-api/util/predicates"
64
65
)
65
66
@@ -117,14 +118,13 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt
117
118
handler .EnqueueRequestsFromMapFunc (r .MachineToMachineSets ),
118
119
).
119
120
WithOptions (options ).
120
- WithEventFilter (predicates .ResourceNotPausedAndHasFilterLabel (mgr .GetScheme (), predicateLog , r .WatchFilterValue )).
121
+ WithEventFilter (predicates .ResourceHasFilterLabel (mgr .GetScheme (), predicateLog , r .WatchFilterValue )).
121
122
Watches (
122
123
& clusterv1.Cluster {},
123
124
handler .EnqueueRequestsFromMapFunc (clusterToMachineSets ),
124
125
builder .WithPredicates (
125
126
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
126
127
predicates .All (mgr .GetScheme (), predicateLog ,
127
- predicates .ClusterUnpaused (mgr .GetScheme (), predicateLog ),
128
128
predicates .ResourceHasFilterLabel (mgr .GetScheme (), predicateLog , r .WatchFilterValue ),
129
129
),
130
130
),
@@ -170,10 +170,8 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
170
170
return ctrl.Result {}, err
171
171
}
172
172
173
- // Return early if the object or Cluster is paused.
174
- if annotations .IsPaused (cluster , machineSet ) {
175
- log .Info ("Reconciliation is paused for this object" )
176
- return ctrl.Result {}, nil
173
+ if isPaused , conditionChanged , err := paused .EnsurePausedCondition (ctx , r .Client , cluster , machineSet ); err != nil || isPaused || conditionChanged {
174
+ return ctrl.Result {}, err
177
175
}
178
176
179
177
// Initialize the patch helper
@@ -189,6 +187,12 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
189
187
}
190
188
}()
191
189
190
+ // Return early if the object or Cluster is paused.
191
+ if annotations .IsPaused (cluster , machineSet ) {
192
+ log .Info ("Reconciliation is paused for this object" )
193
+ return ctrl.Result {}, nil
194
+ }
195
+
192
196
// Handle deletion reconciliation loop.
193
197
if ! machineSet .DeletionTimestamp .IsZero () {
194
198
return ctrl.Result {}, r .reconcileDelete (ctx , machineSet )
0 commit comments