Skip to content

Commit 5335718

Browse files
authored
Merge pull request #5379 from k8s-infra-cherrypick-robot/cherry-pick-5358-to-release-0.4
🐛 Use the watch filter label when watching resources
2 parents 6299442 + 4836c37 commit 5335718

File tree

6 files changed

+21
-7
lines changed

6 files changed

+21
-7
lines changed

bootstrap/kubeadm/controllers/kubeadmconfig_controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@ func (r *KubeadmConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl
9898
b := ctrl.NewControllerManagedBy(mgr).
9999
For(&bootstrapv1.KubeadmConfig{}).
100100
WithOptions(options).
101-
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
102101
Watches(
103102
&source.Kind{Type: &clusterv1.Machine{}},
104103
handler.EnqueueRequestsFromMapFunc(r.MachineToBootstrapMapFunc),
105-
)
104+
).WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue))
106105

107106
if feature.Gates.Enabled(feature.MachinePool) {
108107
b = b.Watches(

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)