Skip to content

Commit

Permalink
Merge pull request #5089 from nojnhuh/aso-concurrency
Browse files Browse the repository at this point in the history
honor *-concurrency flags for ASO API controllers
  • Loading branch information
k8s-ci-robot authored Aug 27, 2024
2 parents c016964 + 6b2e3ec commit 07088c2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
4 changes: 3 additions & 1 deletion controllers/agentpooladopt_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion controllers/azureasomanagedcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -66,14 +67,15 @@ 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),
)
defer done()

c, err := ctrl.NewControllerManagedBy(mgr).
WithOptions(options).
For(&infrav1alpha.AzureASOManagedCluster{}).
WithEventFilter(predicates.ResourceHasFilterLabel(log, r.WatchFilterValue)).
WithEventFilter(predicates.ResourceIsNotExternallyManaged(log)).
Expand Down
4 changes: 3 additions & 1 deletion controllers/azureasomanagedcontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -55,14 +56,15 @@ 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),
)
defer done()

c, err := ctrl.NewControllerManagedBy(mgr).
WithOptions(options).
For(&infrav1alpha.AzureASOManagedControlPlane{}).
WithEventFilter(predicates.ResourceHasFilterLabel(log, r.WatchFilterValue)).
Watches(&clusterv1.Cluster{},
Expand Down
4 changes: 3 additions & 1 deletion controllers/azureasomanagedmachinepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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),
Expand All @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion controllers/managedclusteradopt_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,15 +516,15 @@ 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)
}

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)
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 07088c2

Please sign in to comment.