Skip to content

Commit 4b2c30b

Browse files
committed
inmemorycluster: set v1beta2 Paused condition
1 parent a39ea9a commit 4b2c30b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
kerrors "k8s.io/apimachinery/pkg/util/errors"
2727
"k8s.io/klog/v2"
2828
ctrl "sigs.k8s.io/controller-runtime"
29-
"sigs.k8s.io/controller-runtime/pkg/builder"
3029
"sigs.k8s.io/controller-runtime/pkg/client"
3130
"sigs.k8s.io/controller-runtime/pkg/controller"
3231
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -39,6 +38,7 @@ import (
3938
"sigs.k8s.io/cluster-api/util"
4039
"sigs.k8s.io/cluster-api/util/finalizers"
4140
"sigs.k8s.io/cluster-api/util/patch"
41+
"sigs.k8s.io/cluster-api/util/paused"
4242
"sigs.k8s.io/cluster-api/util/predicates"
4343
)
4444

@@ -91,6 +91,10 @@ func (r *InMemoryClusterReconciler) Reconcile(ctx context.Context, req ctrl.Requ
9191
log = log.WithValues("Cluster", klog.KObj(cluster))
9292
ctx = ctrl.LoggerInto(ctx, log)
9393

94+
if isPaused, conditionChanged, err := paused.EnsurePausedCondition(ctx, r.Client, cluster, inMemoryCluster); err != nil || isPaused || conditionChanged {
95+
return ctrl.Result{}, err
96+
}
97+
9498
// Initialize the patch helper
9599
patchHelper, err := patch.NewHelper(inMemoryCluster, r.Client)
96100
if err != nil {
@@ -211,13 +215,10 @@ func (r *InMemoryClusterReconciler) SetupWithManager(ctx context.Context, mgr ct
211215
err := ctrl.NewControllerManagedBy(mgr).
212216
For(&infrav1.InMemoryCluster{}).
213217
WithOptions(options).
214-
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)).
218+
WithEventFilter(predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)).
215219
Watches(
216220
&clusterv1.Cluster{},
217221
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("InMemoryCluster"), mgr.GetClient(), &infrav1.InMemoryCluster{})),
218-
builder.WithPredicates(
219-
predicates.ClusterUnpaused(mgr.GetScheme(), predicateLog),
220-
),
221222
).Complete(r)
222223
if err != nil {
223224
return errors.Wrap(err, "failed setting up with a controller manager")

0 commit comments

Comments
 (0)