Skip to content

Commit 449107a

Browse files
committed
predicates fixup
1 parent 5b6b49a commit 449107a

File tree

8 files changed

+32
-5
lines changed

8 files changed

+32
-5
lines changed

exp/internal/controllers/machinepool_controller.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ func (r *MachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M
114114
&clusterv1.Cluster{},
115115
handler.EnqueueRequestsFromMapFunc(clusterToMachinePools),
116116
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
117-
builder.WithPredicates(predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue)),
117+
builder.WithPredicates(
118+
predicates.All(mgr.GetScheme(), predicateLog,
119+
predicates.ClusterPausedTransitions(mgr.GetScheme(), predicateLog),
120+
predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue),
121+
),
122+
),
118123
).
119124
WatchesRawSource(r.ClusterCache.GetClusterSource("machinepool", clusterToMachinePools)).
120125
Build(r)

internal/controllers/machinedeployment/machinedeployment_controller.go

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"k8s.io/client-go/tools/record"
3131
"k8s.io/klog/v2"
3232
ctrl "sigs.k8s.io/controller-runtime"
33+
"sigs.k8s.io/controller-runtime/pkg/builder"
3334
"sigs.k8s.io/controller-runtime/pkg/client"
3435
"sigs.k8s.io/controller-runtime/pkg/controller"
3536
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -97,6 +98,9 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt
9798
Watches(
9899
&clusterv1.Cluster{},
99100
handler.EnqueueRequestsFromMapFunc(clusterToMachineDeployments),
101+
builder.WithPredicates(
102+
predicates.ClusterPausedTransitions(mgr.GetScheme(), predicateLog),
103+
),
100104
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
101105
).Complete(r)
102106
if err != nil {

internal/controllers/machinehealthcheck/machinehealthcheck_controller.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt
100100
handler.EnqueueRequestsFromMapFunc(r.clusterToMachineHealthCheck),
101101
builder.WithPredicates(
102102
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
103-
predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue),
103+
predicates.All(mgr.GetScheme(), predicateLog,
104+
predicates.ClusterPausedTransitions(mgr.GetScheme(), predicateLog),
105+
predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue),
106+
),
104107
),
105108
).
106109
WatchesRawSource(r.ClusterCache.GetClusterSource("machinehealthcheck", r.clusterToMachineHealthCheck)).

internal/controllers/machineset/machineset_controller.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ func (r *Reconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, opt
123123
handler.EnqueueRequestsFromMapFunc(clusterToMachineSets),
124124
builder.WithPredicates(
125125
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
126-
predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue),
126+
predicates.All(mgr.GetScheme(), predicateLog,
127+
predicates.ClusterPausedTransitions(mgr.GetScheme(), predicateLog),
128+
predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue),
129+
),
127130
),
128131
).
129132
WatchesRawSource(r.ClusterCache.GetClusterSource("machineset", clusterToMachineSets)).

test/infrastructure/docker/internal/controllers/dockercluster_controller.go

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
apierrors "k8s.io/apimachinery/pkg/api/errors"
2525
"k8s.io/klog/v2"
2626
ctrl "sigs.k8s.io/controller-runtime"
27+
"sigs.k8s.io/controller-runtime/pkg/builder"
2728
"sigs.k8s.io/controller-runtime/pkg/client"
2829
"sigs.k8s.io/controller-runtime/pkg/controller"
2930
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -209,6 +210,9 @@ func (r *DockerClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl
209210
Watches(
210211
&clusterv1.Cluster{},
211212
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("DockerCluster"), mgr.GetClient(), &infrav1.DockerCluster{})),
213+
builder.WithPredicates(
214+
predicates.ClusterPausedTransitions(mgr.GetScheme(), predicateLog),
215+
),
212216
).Complete(r)
213217
if err != nil {
214218
return errors.Wrap(err, "failed setting up with a controller manager")

test/infrastructure/docker/internal/controllers/dockermachine_controller.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,9 @@ func (r *DockerMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl
497497
Watches(
498498
&clusterv1.Cluster{},
499499
handler.EnqueueRequestsFromMapFunc(clusterToDockerMachines),
500-
builder.WithPredicates(predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), predicateLog)),
500+
builder.WithPredicates(
501+
predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), predicateLog),
502+
),
501503
).
502504
WatchesRawSource(r.ClusterCache.GetClusterSource("dockermachine", clusterToDockerMachines)).
503505
Complete(r)

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

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ 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"
2930
"sigs.k8s.io/controller-runtime/pkg/client"
3031
"sigs.k8s.io/controller-runtime/pkg/controller"
3132
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -219,6 +220,9 @@ func (r *InMemoryClusterReconciler) SetupWithManager(ctx context.Context, mgr ct
219220
Watches(
220221
&clusterv1.Cluster{},
221222
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind("InMemoryCluster"), mgr.GetClient(), &infrav1.InMemoryCluster{})),
223+
builder.WithPredicates(
224+
predicates.ClusterPausedTransitions(mgr.GetScheme(), predicateLog),
225+
),
222226
).Complete(r)
223227
if err != nil {
224228
return errors.Wrap(err, "failed setting up with a controller manager")

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,9 @@ func (r *InMemoryMachineReconciler) SetupWithManager(ctx context.Context, mgr ct
11561156
Watches(
11571157
&clusterv1.Cluster{},
11581158
handler.EnqueueRequestsFromMapFunc(clusterToInMemoryMachines),
1159-
builder.WithPredicates(predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), predicateLog)),
1159+
builder.WithPredicates(
1160+
predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), predicateLog),
1161+
),
11601162
).Complete(r)
11611163
if err != nil {
11621164
return errors.Wrap(err, "failed setting up with a controller manager")

0 commit comments

Comments
 (0)