@@ -26,7 +26,6 @@ import (
26
26
kerrors "k8s.io/apimachinery/pkg/util/errors"
27
27
"k8s.io/klog/v2"
28
28
ctrl "sigs.k8s.io/controller-runtime"
29
- "sigs.k8s.io/controller-runtime/pkg/builder"
30
29
"sigs.k8s.io/controller-runtime/pkg/client"
31
30
"sigs.k8s.io/controller-runtime/pkg/controller"
32
31
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -39,6 +38,7 @@ import (
39
38
"sigs.k8s.io/cluster-api/util"
40
39
"sigs.k8s.io/cluster-api/util/finalizers"
41
40
"sigs.k8s.io/cluster-api/util/patch"
41
+ "sigs.k8s.io/cluster-api/util/paused"
42
42
"sigs.k8s.io/cluster-api/util/predicates"
43
43
)
44
44
@@ -91,6 +91,10 @@ func (r *InMemoryClusterReconciler) Reconcile(ctx context.Context, req ctrl.Requ
91
91
log = log .WithValues ("Cluster" , klog .KObj (cluster ))
92
92
ctx = ctrl .LoggerInto (ctx , log )
93
93
94
+ if isPaused , conditionChanged , err := paused .EnsurePausedCondition (ctx , r .Client , cluster , inMemoryCluster ); err != nil || isPaused || conditionChanged {
95
+ return ctrl.Result {}, err
96
+ }
97
+
94
98
// Initialize the patch helper
95
99
patchHelper , err := patch .NewHelper (inMemoryCluster , r .Client )
96
100
if err != nil {
@@ -211,13 +215,10 @@ func (r *InMemoryClusterReconciler) SetupWithManager(ctx context.Context, mgr ct
211
215
err := ctrl .NewControllerManagedBy (mgr ).
212
216
For (& infrav1.InMemoryCluster {}).
213
217
WithOptions (options ).
214
- WithEventFilter (predicates .ResourceNotPausedAndHasFilterLabel (mgr .GetScheme (), predicateLog , r .WatchFilterValue )).
218
+ WithEventFilter (predicates .ResourceHasFilterLabel (mgr .GetScheme (), predicateLog , r .WatchFilterValue )).
215
219
Watches (
216
220
& clusterv1.Cluster {},
217
221
handler .EnqueueRequestsFromMapFunc (util .ClusterToInfrastructureMapFunc (ctx , infrav1 .GroupVersion .WithKind ("InMemoryCluster" ), mgr .GetClient (), & infrav1.InMemoryCluster {})),
218
- builder .WithPredicates (
219
- predicates .ClusterUnpaused (mgr .GetScheme (), predicateLog ),
220
- ),
221
222
).Complete (r )
222
223
if err != nil {
223
224
return errors .Wrap (err , "failed setting up with a controller manager" )
0 commit comments