From 9b80dea3572d6b6192d750bc743eecd5137ac61a Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Tue, 15 Oct 2024 08:44:59 +0200 Subject: [PATCH] inmemorymachine: set v1beta2 Paused condition --- .../internal/controllers/inmemorymachine_controller.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller.go b/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller.go index e45d4aee2fde..0684538717bd 100644 --- a/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller.go +++ b/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller.go @@ -54,6 +54,7 @@ import ( "sigs.k8s.io/cluster-api/util/finalizers" clog "sigs.k8s.io/cluster-api/util/log" "sigs.k8s.io/cluster-api/util/patch" + "sigs.k8s.io/cluster-api/util/paused" "sigs.k8s.io/cluster-api/util/predicates" "sigs.k8s.io/cluster-api/util/secret" ) @@ -123,6 +124,10 @@ func (r *InMemoryMachineReconciler) Reconcile(ctx context.Context, req ctrl.Requ log = log.WithValues("Cluster", klog.KObj(cluster)) ctx = ctrl.LoggerInto(ctx, log) + if isPaused, conditionChanged, err := paused.EnsurePausedCondition(ctx, r.Client, cluster, inMemoryMachine); err != nil || isPaused || conditionChanged { + return ctrl.Result{}, err + } + // Return early if the object or Cluster is paused. if annotations.IsPaused(cluster, inMemoryMachine) { log.Info("Reconciliation is paused for this object") @@ -1146,7 +1151,7 @@ func (r *InMemoryMachineReconciler) SetupWithManager(ctx context.Context, mgr ct err = ctrl.NewControllerManagedBy(mgr). For(&infrav1.InMemoryMachine{}). WithOptions(options). - WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)). + WithEventFilter(predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)). Watches( &clusterv1.Machine{}, handler.EnqueueRequestsFromMapFunc(util.MachineToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("InMemoryMachine"))), @@ -1159,7 +1164,7 @@ func (r *InMemoryMachineReconciler) SetupWithManager(ctx context.Context, mgr ct &clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc(clusterToInMemoryMachines), builder.WithPredicates( - predicates.ClusterUnpausedAndInfrastructureReady(mgr.GetScheme(), predicateLog), + predicates.ClusterInfrastructureReady(mgr.GetScheme(), predicateLog), ), ).Complete(r) if err != nil {