diff --git a/cmd/agent/app/agent.go b/cmd/agent/app/agent.go index a90d33c45..2ee664dca 100644 --- a/cmd/agent/app/agent.go +++ b/cmd/agent/app/agent.go @@ -187,6 +187,7 @@ func setupControllers(mgr controllerruntime.Manager, opts *options.Options, stop ClusterAPIQPS: opts.ClusterAPIQPS, ClusterAPIBurst: opts.ClusterAPIBurst, ConcurrentWorkSyncs: opts.ConcurrentWorkSyncs, + RateLimiterOptions: opts.RateLimiterOpts, }, StopChan: stopChan, } @@ -219,6 +220,7 @@ func startClusterStatusController(ctx controllerscontext.Context) (bool, error) ClusterLeaseDuration: ctx.Opts.ClusterLeaseDuration, ClusterLeaseRenewIntervalFraction: ctx.Opts.ClusterLeaseRenewIntervalFraction, ClusterCacheSyncTimeout: ctx.Opts.ClusterCacheSyncTimeout, + RateLimiterOptions: ctx.Opts.RateLimiterOptions, } if err := clusterStatusController.SetupWithManager(ctx.Mgr); err != nil { return false, err @@ -235,6 +237,7 @@ func startExecutionController(ctx controllerscontext.Context) (bool, error) { PredicateFunc: helper.NewExecutionPredicateOnAgent(), InformerManager: informermanager.GetInstance(), ClusterClientSetFunc: util.NewClusterDynamicClientSetForAgent, + RatelimiterOptions: ctx.Opts.RateLimiterOptions, } if err := executionController.SetupWithManager(ctx.Mgr); err != nil { return false, err @@ -254,6 +257,7 @@ func startWorkStatusController(ctx controllerscontext.Context) (bool, error) { ClusterClientSetFunc: util.NewClusterDynamicClientSetForAgent, ClusterCacheSyncTimeout: ctx.Opts.ClusterCacheSyncTimeout, ConcurrentWorkStatusSyncs: ctx.Opts.ConcurrentWorkSyncs, + RateLimiterOptions: ctx.Opts.RateLimiterOptions, } workStatusController.RunWorkQueue() if err := workStatusController.SetupWithManager(ctx.Mgr); err != nil { diff --git a/cmd/agent/app/options/options.go b/cmd/agent/app/options/options.go index 7a93cef62..a10220bdb 100644 --- a/cmd/agent/app/options/options.go +++ b/cmd/agent/app/options/options.go @@ -10,6 +10,7 @@ import ( "k8s.io/client-go/tools/leaderelection/resourcelock" componentbaseconfig "k8s.io/component-base/config" + "github.com/karmada-io/karmada/pkg/sharedcli/ratelimiterflag" "github.com/karmada-io/karmada/pkg/util" ) @@ -61,6 +62,8 @@ type Options struct { // ConcurrentWorkSyncs is the number of work objects that are // allowed to sync concurrently. ConcurrentWorkSyncs int + + RateLimiterOpts ratelimiterflag.Options } // NewOptions builds an default scheduler options. @@ -105,4 +108,5 @@ func (o *Options) AddFlags(fs *pflag.FlagSet, allControllers []string) { fs.DurationVar(&o.ResyncPeriod.Duration, "resync-period", 0, "Base frequency the informers are resynced.") fs.IntVar(&o.ConcurrentClusterSyncs, "concurrent-cluster-syncs", 5, "The number of Clusters that are allowed to sync concurrently.") fs.IntVar(&o.ConcurrentWorkSyncs, "concurrent-work-syncs", 5, "The number of Works that are allowed to sync concurrently.") + o.RateLimiterOpts.AddFlags(fs) } diff --git a/cmd/controller-manager/app/controllermanager.go b/cmd/controller-manager/app/controllermanager.go index fe4a5ba9a..9eea80808 100644 --- a/cmd/controller-manager/app/controllermanager.go +++ b/cmd/controller-manager/app/controllermanager.go @@ -275,7 +275,7 @@ func startExecutionController(ctx controllerscontext.Context) (enabled bool, err PredicateFunc: helper.NewExecutionPredicate(ctx.Mgr), InformerManager: informermanager.GetInstance(), ClusterClientSetFunc: util.NewClusterDynamicClientSet, - RatelimiterOption: ctx.Opts.RateLimiterOptions, + RatelimiterOptions: ctx.Opts.RateLimiterOptions, } if err := executionController.SetupWithManager(ctx.Mgr); err != nil { return false, err diff --git a/pkg/controllers/execution/execution_controller.go b/pkg/controllers/execution/execution_controller.go index 19b7829b2..2e3d719df 100644 --- a/pkg/controllers/execution/execution_controller.go +++ b/pkg/controllers/execution/execution_controller.go @@ -43,7 +43,7 @@ type Controller struct { PredicateFunc predicate.Predicate InformerManager informermanager.MultiClusterInformerManager ClusterClientSetFunc func(clusterName string, client client.Client) (*util.DynamicClusterClient, error) - RatelimiterOption ratelimiterflag.Options + RatelimiterOptions ratelimiterflag.Options } // Reconcile performs a full reconciliation for the object referred to by the Request. @@ -104,7 +104,7 @@ func (c *Controller) SetupWithManager(mgr controllerruntime.Manager) error { WithEventFilter(predicate.GenerationChangedPredicate{}). WithEventFilter(c.PredicateFunc). WithOptions(controller.Options{ - RateLimiter: ratelimiterflag.DefaultControllerRateLimiter(c.RatelimiterOption), + RateLimiter: ratelimiterflag.DefaultControllerRateLimiter(c.RatelimiterOptions), }). Complete(c) }