Skip to content

Commit cd86f51

Browse files
committed
inmemorymachine: set v1beta2 Paused condition
1 parent 7b518bb commit cd86f51

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import (
5454
"sigs.k8s.io/cluster-api/util/finalizers"
5555
clog "sigs.k8s.io/cluster-api/util/log"
5656
"sigs.k8s.io/cluster-api/util/patch"
57+
"sigs.k8s.io/cluster-api/util/paused"
5758
"sigs.k8s.io/cluster-api/util/predicates"
5859
"sigs.k8s.io/cluster-api/util/secret"
5960
)
@@ -123,6 +124,10 @@ func (r *InMemoryMachineReconciler) Reconcile(ctx context.Context, req ctrl.Requ
123124
log = log.WithValues("Cluster", klog.KObj(cluster))
124125
ctx = ctrl.LoggerInto(ctx, log)
125126

127+
if isPaused, conditionChanged, err := paused.EnsurePausedCondition(ctx, r.Client, cluster, inMemoryMachine); err != nil || isPaused || conditionChanged {
128+
return ctrl.Result{}, err
129+
}
130+
126131
// Return early if the object or Cluster is paused.
127132
if annotations.IsPaused(cluster, inMemoryMachine) {
128133
log.Info("Reconciliation is paused for this object")
@@ -1146,7 +1151,7 @@ func (r *InMemoryMachineReconciler) SetupWithManager(ctx context.Context, mgr ct
11461151
err = ctrl.NewControllerManagedBy(mgr).
11471152
For(&infrav1.InMemoryMachine{}).
11481153
WithOptions(options).
1149-
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)).
1154+
WithEventFilter(predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)).
11501155
Watches(
11511156
&clusterv1.Machine{},
11521157
handler.EnqueueRequestsFromMapFunc(util.MachineToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("InMemoryMachine"))),
@@ -1159,7 +1164,7 @@ func (r *InMemoryMachineReconciler) SetupWithManager(ctx context.Context, mgr ct
11591164
&clusterv1.Cluster{},
11601165
handler.EnqueueRequestsFromMapFunc(clusterToInMemoryMachines),
11611166
builder.WithPredicates(
1162-
predicates.ClusterUnpausedAndInfrastructureReady(mgr.GetScheme(), predicateLog),
1167+
predicates.ClusterInfrastructureReady(mgr.GetScheme(), predicateLog),
11631168
),
11641169
).Complete(r)
11651170
if err != nil {

0 commit comments

Comments
 (0)