Skip to content

Commit 830f0e3

Browse files
committed
Add missing watch filter label
1 parent 2e16aff commit 830f0e3

12 files changed

+22
-1
lines changed

controllers/azurecluster_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func (r *AzureClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.
9393
&source.Kind{Type: &clusterv1.Cluster{}},
9494
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("AzureCluster"))),
9595
predicates.ClusterUnpaused(log),
96+
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
9697
); err != nil {
9798
return errors.Wrap(err, "failed adding a watch for ready clusters")
9899
}

controllers/azureidentity_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func (r *AzureIdentityReconciler) SetupWithManager(ctx context.Context, mgr ctrl
8484
&source.Kind{Type: &clusterv1.Cluster{}},
8585
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(infrav1.GroupVersion.WithKind("AzureCluster"))),
8686
predicates.ClusterUnpaused(log),
87+
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
8788
); err != nil {
8889
return errors.Wrap(err, "failed adding a watch for ready clusters")
8990
}

controllers/azurejson_machine_controller.go

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
3434
"sigs.k8s.io/cluster-api/util"
3535
"sigs.k8s.io/cluster-api/util/annotations"
36+
"sigs.k8s.io/cluster-api/util/predicates"
3637
ctrl "sigs.k8s.io/controller-runtime"
3738
"sigs.k8s.io/controller-runtime/pkg/client"
3839
"sigs.k8s.io/controller-runtime/pkg/controller"
@@ -52,13 +53,15 @@ type AzureJSONMachineReconciler struct {
5253
Log logr.Logger
5354
Recorder record.EventRecorder
5455
ReconcileTimeout time.Duration
56+
WatchFilterValue string
5557
}
5658

5759
// SetupWithManager initializes this controller with a manager.
5860
func (r *AzureJSONMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
5961
return ctrl.NewControllerManagedBy(mgr).
6062
For(&infrav1.AzureMachine{}).
6163
WithEventFilter(filterUnclonedMachinesPredicate{log: r.Log}).
64+
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
6265
Owns(&corev1.Secret{}).
6366
Complete(r)
6467
}

controllers/azurejson_machinepool_controller.go

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"k8s.io/apimachinery/pkg/types"
3232
"k8s.io/client-go/tools/record"
3333
"sigs.k8s.io/cluster-api/util"
34+
"sigs.k8s.io/cluster-api/util/predicates"
3435
ctrl "sigs.k8s.io/controller-runtime"
3536
"sigs.k8s.io/controller-runtime/pkg/client"
3637
"sigs.k8s.io/controller-runtime/pkg/controller"
@@ -49,12 +50,14 @@ type AzureJSONMachinePoolReconciler struct {
4950
Log logr.Logger
5051
Recorder record.EventRecorder
5152
ReconcileTimeout time.Duration
53+
WatchFilterValue string
5254
}
5355

5456
// SetupWithManager initializes this controller with a manager.
5557
func (r *AzureJSONMachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
5658
return ctrl.NewControllerManagedBy(mgr).
5759
For(&expv1.AzureMachinePool{}).
60+
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
5861
Owns(&corev1.Secret{}).
5962
Complete(r)
6063
}

controllers/azurejson_machinetemplate_controller.go

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"k8s.io/client-go/tools/record"
3333
"sigs.k8s.io/cluster-api/util"
3434
"sigs.k8s.io/cluster-api/util/annotations"
35+
"sigs.k8s.io/cluster-api/util/predicates"
3536
ctrl "sigs.k8s.io/controller-runtime"
3637
"sigs.k8s.io/controller-runtime/pkg/client"
3738
"sigs.k8s.io/controller-runtime/pkg/controller"
@@ -49,13 +50,15 @@ type AzureJSONTemplateReconciler struct {
4950
Log logr.Logger
5051
Recorder record.EventRecorder
5152
ReconcileTimeout time.Duration
53+
WatchFilterValue string
5254
}
5355

5456
// SetupWithManager initializes this controller with a manager.
5557
func (r *AzureJSONTemplateReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
5658
return ctrl.NewControllerManagedBy(mgr).
5759
WithOptions(options).
5860
For(&infrav1.AzureMachineTemplate{}).
61+
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue)).
5962
Owns(&corev1.Secret{}).
6063
Complete(r)
6164
}

controllers/azuremachine_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func (r *AzureMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.
113113
&source.Kind{Type: &clusterv1.Cluster{}},
114114
handler.EnqueueRequestsFromMapFunc(azureMachineMapper),
115115
predicates.ClusterUnpausedAndInfrastructureReady(log),
116+
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
116117
); err != nil {
117118
return errors.Wrap(err, "failed adding a watch for ready clusters")
118119
}

exp/controllers/azuremachinepool_controller.go

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ func (ampr *AzureMachinePoolReconciler) SetupWithManager(ctx context.Context, mg
126126
&source.Kind{Type: &infrav1exp.AzureMachinePoolMachine{}},
127127
handler.EnqueueRequestsFromMapFunc(AzureMachinePoolMachineMapper(mgr.GetScheme(), log)),
128128
MachinePoolMachineHasStateOrVersionChange(log),
129+
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), ampr.WatchFilterValue),
129130
); err != nil {
130131
return errors.Wrap(err, "failed adding a watch for AzureMachinePoolMachine")
131132
}
@@ -140,6 +141,7 @@ func (ampr *AzureMachinePoolReconciler) SetupWithManager(ctx context.Context, mg
140141
&source.Kind{Type: &clusterv1.Cluster{}},
141142
handler.EnqueueRequestsFromMapFunc(azureMachinePoolMapper),
142143
predicates.ClusterUnpausedAndInfrastructureReady(log),
144+
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), ampr.WatchFilterValue),
143145
); err != nil {
144146
return errors.Wrap(err, "failed adding a watch for ready clusters")
145147
}

exp/controllers/azuremachinepoolmachine_controller.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (ampmr *AzureMachinePoolMachineController) SetupWithManager(ctx context.Con
9898
c, err := ctrl.NewControllerManagedBy(mgr).
9999
WithOptions(options.Options).
100100
For(&infrav1exp.AzureMachinePoolMachine{}).
101-
WithEventFilter(predicates.ResourceNotPaused(log)). // don't queue reconcile if resource is paused
101+
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), ampmr.WatchFilterValue)).
102102
Build(r)
103103
if err != nil {
104104
return errors.Wrapf(err, "error creating controller")
@@ -109,6 +109,7 @@ func (ampmr *AzureMachinePoolMachineController) SetupWithManager(ctx context.Con
109109
&source.Kind{Type: &infrav1exp.AzureMachinePool{}},
110110
handler.EnqueueRequestsFromMapFunc(AzureMachinePoolToAzureMachinePoolMachines(ctx, mgr.GetClient(), log)),
111111
MachinePoolModelHasChanged(log),
112+
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), ampmr.WatchFilterValue),
112113
); err != nil {
113114
return errors.Wrapf(err, "failed adding a watch for AzureMachinePool model changes")
114115
}

exp/controllers/azuremanagedcluster_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func (r *AzureManagedClusterReconciler) SetupWithManager(ctx context.Context, mg
8383
&source.Kind{Type: &clusterv1.Cluster{}},
8484
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(infrav1exp.GroupVersion.WithKind("AzureManagedCluster"))),
8585
predicates.ClusterUnpaused(log),
86+
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
8687
); err != nil {
8788
return errors.Wrap(err, "failed adding a watch for ready clusters")
8889
}

exp/controllers/azuremanagedcontrolplane_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (r *AzureManagedControlPlaneReconciler) SetupWithManager(ctx context.Contex
9595
&source.Kind{Type: &clusterv1.Cluster{}},
9696
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(infrav1exp.GroupVersion.WithKind("AzureManagedControlPlane"))),
9797
predicates.ClusterUnpausedAndInfrastructureReady(log),
98+
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
9899
); err != nil {
99100
return errors.Wrap(err, "failed adding a watch for ready clusters")
100101
}

exp/controllers/azuremanagedmachinepool_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func (r *AzureManagedMachinePoolReconciler) SetupWithManager(ctx context.Context
108108
&source.Kind{Type: &clusterv1.Cluster{}},
109109
handler.EnqueueRequestsFromMapFunc(util.ClusterToInfrastructureMapFunc(infrav1exp.GroupVersion.WithKind("AzureManagedMachinePool"))),
110110
predicates.ClusterUnpausedAndInfrastructureReady(log),
111+
predicates.ResourceNotPausedAndHasFilterLabel(ctrl.LoggerFrom(ctx), r.WatchFilterValue),
111112
); err != nil {
112113
return errors.Wrap(err, "failed adding a watch for ready clusters")
113114
}

main.go

+3
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ func registerControllers(ctx context.Context, mgr manager.Manager) {
342342
Log: ctrl.Log.WithName("controllers").WithName("AzureJSONTemplate"),
343343
Recorder: mgr.GetEventRecorderFor("azurejsontemplate-reconciler"),
344344
ReconcileTimeout: reconcileTimeout,
345+
WatchFilterValue: watchFilterValue,
345346
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureMachineConcurrency}); err != nil {
346347
setupLog.Error(err, "unable to create controller", "controller", "AzureJSONTemplate")
347348
os.Exit(1)
@@ -352,6 +353,7 @@ func registerControllers(ctx context.Context, mgr manager.Manager) {
352353
Log: ctrl.Log.WithName("controllers").WithName("AzureJSONMachine"),
353354
Recorder: mgr.GetEventRecorderFor("azurejsonmachine-reconciler"),
354355
ReconcileTimeout: reconcileTimeout,
356+
WatchFilterValue: watchFilterValue,
355357
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureMachineConcurrency}); err != nil {
356358
setupLog.Error(err, "unable to create controller", "controller", "AzureJSONMachine")
357359
os.Exit(1)
@@ -408,6 +410,7 @@ func registerControllers(ctx context.Context, mgr manager.Manager) {
408410
Log: ctrl.Log.WithName("controllers").WithName("AzureJSONMachinePool"),
409411
Recorder: mgr.GetEventRecorderFor("azurejsonmachinepool-reconciler"),
410412
ReconcileTimeout: reconcileTimeout,
413+
WatchFilterValue: watchFilterValue,
411414
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureMachinePoolConcurrency}); err != nil {
412415
setupLog.Error(err, "unable to create controller", "controller", "AzureJSONMachinePool")
413416
os.Exit(1)

0 commit comments

Comments
 (0)