@@ -55,6 +55,7 @@ import (
55
55
"sigs.k8s.io/cluster-api/util/annotations"
56
56
"sigs.k8s.io/cluster-api/util/collections"
57
57
"sigs.k8s.io/cluster-api/util/conditions"
58
+ v1beta2conditions "sigs.k8s.io/cluster-api/util/conditions/v1beta2"
58
59
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
59
60
"sigs.k8s.io/cluster-api/util/labels/format"
60
61
clog "sigs.k8s.io/cluster-api/util/log"
@@ -116,14 +117,12 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt
116
117
handler .EnqueueRequestsFromMapFunc (r .MachineToMachineSets ),
117
118
).
118
119
WithOptions (options ).
119
- WithEventFilter (predicates .ResourceNotPausedAndHasFilterLabel (mgr .GetScheme (), predicateLog , r .WatchFilterValue )).
120
120
Watches (
121
121
& clusterv1.Cluster {},
122
122
handler .EnqueueRequestsFromMapFunc (clusterToMachineSets ),
123
123
builder .WithPredicates (
124
124
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
125
125
predicates .All (mgr .GetScheme (), predicateLog ,
126
- predicates .ClusterUnpaused (mgr .GetScheme (), predicateLog ),
127
126
predicates .ResourceHasFilterLabel (mgr .GetScheme (), predicateLog , r .WatchFilterValue ),
128
127
),
129
128
),
@@ -164,25 +163,27 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
164
163
return ctrl.Result {}, err
165
164
}
166
165
167
- // Return early if the object or Cluster is paused.
168
- if annotations .IsPaused (cluster , machineSet ) {
169
- log .Info ("Reconciliation is paused for this object" )
170
- return ctrl.Result {}, nil
171
- }
172
-
173
166
// Initialize the patch helper
174
167
patchHelper , err := patch .NewHelper (machineSet , r .Client )
175
168
if err != nil {
176
169
return ctrl.Result {}, err
177
170
}
178
171
179
172
defer func () {
173
+ v1beta2conditions .SetPausedCondition (cluster , machineSet )
174
+
180
175
// Always attempt to patch the object and status after each reconciliation.
181
176
if err := patchMachineSet (ctx , patchHelper , machineSet ); err != nil {
182
177
reterr = kerrors .NewAggregate ([]error {reterr , err })
183
178
}
184
179
}()
185
180
181
+ // Return early if the object or Cluster is paused.
182
+ if annotations .IsPaused (cluster , machineSet ) {
183
+ log .Info ("Reconciliation is paused for this object" )
184
+ return ctrl.Result {}, nil
185
+ }
186
+
186
187
// Handle deletion reconciliation loop.
187
188
if ! machineSet .DeletionTimestamp .IsZero () {
188
189
return ctrl.Result {}, r .reconcileDelete (ctx , machineSet )
@@ -226,6 +227,9 @@ func patchMachineSet(ctx context.Context, patchHelper *patch.Helper, machineSet
226
227
clusterv1 .ResizedCondition ,
227
228
clusterv1 .MachinesReadyCondition ,
228
229
}},
230
+ patch.WithOwnedV1Beta2Conditions {Conditions : []string {
231
+ clusterv1 .MachineSetPausedV1Beta2Condition ,
232
+ }},
229
233
)
230
234
return patchHelper .Patch (ctx , machineSet , options ... )
231
235
}
0 commit comments