diff --git a/controllers/agentpooladopt_controller.go b/controllers/agentpooladopt_controller.go index 863863b07d8..f5e6b26089f 100644 --- a/controllers/agentpooladopt_controller.go +++ b/controllers/agentpooladopt_controller.go @@ -31,6 +31,7 @@ import ( expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" ) @@ -41,8 +42,9 @@ type AgentPoolAdoptReconciler struct { } // SetupWithManager sets up the controller with the Manager. -func (r *AgentPoolAdoptReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error { +func (r *AgentPoolAdoptReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { _, err := ctrl.NewControllerManagedBy(mgr). + WithOptions(options). For(&asocontainerservicev1.ManagedClustersAgentPool{}). WithEventFilter(predicate.Funcs{ UpdateFunc: func(ev event.UpdateEvent) bool { diff --git a/controllers/azureasomanagedcluster_controller.go b/controllers/azureasomanagedcluster_controller.go index e3b6014a244..2c2a4ef2399 100644 --- a/controllers/azureasomanagedcluster_controller.go +++ b/controllers/azureasomanagedcluster_controller.go @@ -35,6 +35,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" @@ -66,7 +67,7 @@ type resourceReconciler interface { } // SetupWithManager sets up the controller with the Manager. -func (r *AzureASOManagedClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error { +func (r *AzureASOManagedClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedClusterReconciler.SetupWithManager", tele.KVP("controller", infrav1alpha.AzureASOManagedClusterKind), @@ -74,6 +75,7 @@ func (r *AzureASOManagedClusterReconciler) SetupWithManager(ctx context.Context, defer done() c, err := ctrl.NewControllerManagedBy(mgr). + WithOptions(options). For(&infrav1alpha.AzureASOManagedCluster{}). WithEventFilter(predicates.ResourceHasFilterLabel(log, r.WatchFilterValue)). WithEventFilter(predicates.ResourceIsNotExternallyManaged(log)). diff --git a/controllers/azureasomanagedcontrolplane_controller.go b/controllers/azureasomanagedcontrolplane_controller.go index 969ee3728b2..3d8ed0f310a 100644 --- a/controllers/azureasomanagedcontrolplane_controller.go +++ b/controllers/azureasomanagedcontrolplane_controller.go @@ -39,6 +39,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" @@ -55,7 +56,7 @@ type AzureASOManagedControlPlaneReconciler struct { } // SetupWithManager sets up the controller with the Manager. -func (r *AzureASOManagedControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error { +func (r *AzureASOManagedControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { _, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedControlPlaneReconciler.SetupWithManager", tele.KVP("controller", infrav1alpha.AzureASOManagedControlPlaneKind), @@ -63,6 +64,7 @@ func (r *AzureASOManagedControlPlaneReconciler) SetupWithManager(ctx context.Con defer done() c, err := ctrl.NewControllerManagedBy(mgr). + WithOptions(options). For(&infrav1alpha.AzureASOManagedControlPlane{}). WithEventFilter(predicates.ResourceHasFilterLabel(log, r.WatchFilterValue)). Watches(&clusterv1.Cluster{}, diff --git a/controllers/azureasomanagedmachinepool_controller.go b/controllers/azureasomanagedmachinepool_controller.go index 4b2bde7a90c..d2e0def14ac 100644 --- a/controllers/azureasomanagedmachinepool_controller.go +++ b/controllers/azureasomanagedmachinepool_controller.go @@ -41,6 +41,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" @@ -61,7 +62,7 @@ type ClusterTracker interface { } // SetupWithManager sets up the controller with the Manager. -func (r *AzureASOManagedMachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error { +func (r *AzureASOManagedMachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { _, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedMachinePoolReconciler.SetupWithManager", tele.KVP("controller", infrav1alpha.AzureASOManagedMachinePoolKind), @@ -74,6 +75,7 @@ func (r *AzureASOManagedMachinePoolReconciler) SetupWithManager(ctx context.Cont } c, err := ctrl.NewControllerManagedBy(mgr). + WithOptions(options). For(&infrav1alpha.AzureASOManagedMachinePool{}). WithEventFilter(predicates.ResourceHasFilterLabel(log, r.WatchFilterValue)). Watches( diff --git a/controllers/managedclusteradopt_controller.go b/controllers/managedclusteradopt_controller.go index 7be79d9466a..23a67ba1106 100644 --- a/controllers/managedclusteradopt_controller.go +++ b/controllers/managedclusteradopt_controller.go @@ -30,6 +30,7 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" ) @@ -45,8 +46,9 @@ type ManagedClusterAdoptReconciler struct { } // SetupWithManager sets up the controller with the Manager. -func (r *ManagedClusterAdoptReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error { +func (r *ManagedClusterAdoptReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { _, err := ctrl.NewControllerManagedBy(mgr). + WithOptions(options). For(&asocontainerservicev1.ManagedCluster{}). WithEventFilter(predicate.Funcs{ UpdateFunc: func(ev event.UpdateEvent) bool { diff --git a/main.go b/main.go index 9b18cf39234..206a4632836 100644 --- a/main.go +++ b/main.go @@ -516,7 +516,7 @@ func registerControllers(ctx context.Context, mgr manager.Manager) { if err := (&controllers.AzureASOManagedClusterReconciler{ Client: mgr.GetClient(), WatchFilterValue: watchFilterValue, - }).SetupWithManager(ctx, mgr); err != nil { + }).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureClusterConcurrency}); err != nil { setupLog.Error(err, "unable to create controller", "controller", "AzureASOManagedCluster") os.Exit(1) } @@ -524,7 +524,7 @@ func registerControllers(ctx context.Context, mgr manager.Manager) { if err := (&controllers.AzureASOManagedControlPlaneReconciler{ Client: mgr.GetClient(), WatchFilterValue: watchFilterValue, - }).SetupWithManager(ctx, mgr); err != nil { + }).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureClusterConcurrency}); err != nil { setupLog.Error(err, "unable to create controller", "controller", "AzureASOManagedControlPlane") os.Exit(1) } @@ -557,21 +557,21 @@ func registerControllers(ctx context.Context, mgr manager.Manager) { Client: mgr.GetClient(), WatchFilterValue: watchFilterValue, Tracker: tracker, - }).SetupWithManager(ctx, mgr); err != nil { + }).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureMachinePoolConcurrency}); err != nil { setupLog.Error(err, "unable to create controller", "controller", "AzureASOManagedMachinePool") os.Exit(1) } if err := (&controllers.ManagedClusterAdoptReconciler{ Client: mgr.GetClient(), - }).SetupWithManager(ctx, mgr); err != nil { + }).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureClusterConcurrency}); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ManagedCluster") os.Exit(1) } if err := (&controllers.AgentPoolAdoptReconciler{ Client: mgr.GetClient(), - }).SetupWithManager(ctx, mgr); err != nil { + }).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: azureMachinePoolConcurrency}); err != nil { setupLog.Error(err, "unable to create controller", "controller", "AgentPool") os.Exit(1) }