Skip to content

Commit b98cd3a

Browse files
committed
🐛 Use the watch filter label when watching resources
1 parent 8bbfff6 commit b98cd3a

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

controllers/machine_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ func (r *MachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manag
103103
&source.Kind{Type: &clusterv1.Cluster{}},
104104
handler.EnqueueRequestsFromMapFunc(clusterToMachines),
105105
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
106-
predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)),
106+
predicates.All(ctrl.LoggerFrom(ctx),
107+
predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)),
108+
predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
109+
),
107110
)
108111
if err != nil {
109112
return errors.Wrap(err, "failed to add Watch for Clusters to controller manager")

controllers/machinedeployment_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ func (r *MachineDeploymentReconciler) SetupWithManager(ctx context.Context, mgr
8383
&source.Kind{Type: &clusterv1.Cluster{}},
8484
handler.EnqueueRequestsFromMapFunc(clusterToMachineDeployments),
8585
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
86-
predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)),
86+
predicates.All(ctrl.LoggerFrom(ctx),
87+
predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)),
88+
predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
89+
),
8790
)
8891
if err != nil {
8992
return errors.Wrap(err, "failed to add Watch for Clusters to controller manager")

controllers/machinehealthcheck_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ func (r *MachineHealthCheckReconciler) SetupWithManager(ctx context.Context, mgr
9797
&source.Kind{Type: &clusterv1.Cluster{}},
9898
handler.EnqueueRequestsFromMapFunc(r.clusterToMachineHealthCheck),
9999
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
100-
predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)),
100+
predicates.All(ctrl.LoggerFrom(ctx),
101+
predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)),
102+
predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
103+
),
101104
)
102105
if err != nil {
103106
return errors.Wrap(err, "failed to add Watch for Clusters to controller manager")

controllers/machineset_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ func (r *MachineSetReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
9898
&source.Kind{Type: &clusterv1.Cluster{}},
9999
handler.EnqueueRequestsFromMapFunc(clusterToMachineSets),
100100
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
101-
predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)),
101+
predicates.All(ctrl.LoggerFrom(ctx),
102+
predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)),
103+
predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
104+
),
102105
)
103106
if err != nil {
104107
return errors.Wrap(err, "failed to add Watch for Clusters to controller manager")

exp/controllers/machinepool_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ func (r *MachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.M
8383
&source.Kind{Type: &clusterv1.Cluster{}},
8484
handler.EnqueueRequestsFromMapFunc(clusterToMachinePools),
8585
// TODO: should this wait for Cluster.Status.InfrastructureReady similar to Infra Machine resources?
86-
predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)),
86+
predicates.All(ctrl.LoggerFrom(ctx),
87+
predicates.ClusterUnpaused(ctrl.LoggerFrom(ctx)),
88+
predicates.ResourceHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
89+
),
8790
)
8891
if err != nil {
8992
return errors.Wrap(err, "failed adding Watch for Cluster to controller manager")

0 commit comments

Comments
 (0)