@@ -37,9 +37,9 @@ import (
37
37
expinfrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/exp/api/v1beta2"
38
38
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/scope"
39
39
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger"
40
+ "sigs.k8s.io/cluster-api-provider-aws/v2/util/paused"
40
41
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
41
42
"sigs.k8s.io/cluster-api/util"
42
- "sigs.k8s.io/cluster-api/util/annotations"
43
43
"sigs.k8s.io/cluster-api/util/patch"
44
44
"sigs.k8s.io/cluster-api/util/predicates"
45
45
)
@@ -82,9 +82,8 @@ func (r *ROSAClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request)
82
82
return reconcile.Result {}, nil
83
83
}
84
84
85
- if annotations .IsPaused (cluster , rosaCluster ) {
86
- log .Info ("ROSACluster or linked Cluster is marked as paused. Won't reconcile" )
87
- return reconcile.Result {}, nil
85
+ if isPaused , conditionChanged , err := paused .EnsurePausedCondition (ctx , r .Client , cluster , rosaCluster ); err != nil || isPaused || conditionChanged {
86
+ return ctrl.Result {}, err
88
87
}
89
88
90
89
log = log .WithValues ("cluster" , cluster .Name )
@@ -127,7 +126,7 @@ func (r *ROSAClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M
127
126
controller , err := ctrl .NewControllerManagedBy (mgr ).
128
127
WithOptions (options ).
129
128
For (rosaCluster ).
130
- WithEventFilter (predicates .ResourceNotPausedAndHasFilterLabel (mgr .GetScheme (), ctrl .LoggerFrom (ctx ), r .WatchFilterValue )).
129
+ WithEventFilter (predicates .ResourceHasFilterLabel (mgr .GetScheme (), ctrl .LoggerFrom (ctx ), r .WatchFilterValue )).
131
130
Build (r )
132
131
133
132
if err != nil {
@@ -138,7 +137,7 @@ func (r *ROSAClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M
138
137
if err = controller .Watch (
139
138
source .Kind [client.Object ](mgr .GetCache (), & clusterv1.Cluster {},
140
139
handler .EnqueueRequestsFromMapFunc (util .ClusterToInfrastructureMapFunc (ctx , infrav1 .GroupVersion .WithKind ("ROSACluster" ), mgr .GetClient (), & expinfrav1.ROSACluster {})),
141
- predicates .ClusterUnpaused (mgr .GetScheme (), log .GetLogger ())),
140
+ predicates .ClusterPausedTransitions (mgr .GetScheme (), log .GetLogger ())),
142
141
); err != nil {
143
142
return fmt .Errorf ("failed adding a watch for ready clusters: %w" , err )
144
143
}
0 commit comments