Skip to content

Commit 909f309

Browse files
committed
machineset: set v1beta2 Paused condition
1 parent 816b1e6 commit 909f309

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

internal/controllers/machineset/machineset_controller.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import (
6060
"sigs.k8s.io/cluster-api/util/labels/format"
6161
clog "sigs.k8s.io/cluster-api/util/log"
6262
"sigs.k8s.io/cluster-api/util/patch"
63+
"sigs.k8s.io/cluster-api/util/paused"
6364
"sigs.k8s.io/cluster-api/util/predicates"
6465
)
6566

@@ -117,14 +118,13 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt
117118
handler.EnqueueRequestsFromMapFunc(r.MachineToMachineSets),
118119
).
119120
WithOptions(options).
120-
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)).
121+
WithEventFilter(predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)).
121122
Watches(
122123
&clusterv1.Cluster{},
123124
handler.EnqueueRequestsFromMapFunc(clusterToMachineSets),
124125
builder.WithPredicates(
125126
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
126127
predicates.All(mgr.GetScheme(), predicateLog,
127-
predicates.ClusterUnpaused(mgr.GetScheme(), predicateLog),
128128
predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue),
129129
),
130130
),
@@ -170,10 +170,8 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
170170
return ctrl.Result{}, err
171171
}
172172

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
177175
}
178176

179177
// Initialize the patch helper
@@ -189,6 +187,12 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
189187
}
190188
}()
191189

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+
192196
// Handle deletion reconciliation loop.
193197
if !machineSet.DeletionTimestamp.IsZero() {
194198
return ctrl.Result{}, r.reconcileDelete(ctx, machineSet)

0 commit comments

Comments
 (0)