add ratelimiter flags for karmada-agent
Signed-off-by: dddddai <dddwq@foxmail.com>
This commit is contained in:
parent
d0553bf3da
commit
e52e02c23a
|
@ -187,6 +187,7 @@ func setupControllers(mgr controllerruntime.Manager, opts *options.Options, stop
|
||||||
ClusterAPIQPS: opts.ClusterAPIQPS,
|
ClusterAPIQPS: opts.ClusterAPIQPS,
|
||||||
ClusterAPIBurst: opts.ClusterAPIBurst,
|
ClusterAPIBurst: opts.ClusterAPIBurst,
|
||||||
ConcurrentWorkSyncs: opts.ConcurrentWorkSyncs,
|
ConcurrentWorkSyncs: opts.ConcurrentWorkSyncs,
|
||||||
|
RateLimiterOptions: opts.RateLimiterOpts,
|
||||||
},
|
},
|
||||||
StopChan: stopChan,
|
StopChan: stopChan,
|
||||||
}
|
}
|
||||||
|
@ -219,6 +220,7 @@ func startClusterStatusController(ctx controllerscontext.Context) (bool, error)
|
||||||
ClusterLeaseDuration: ctx.Opts.ClusterLeaseDuration,
|
ClusterLeaseDuration: ctx.Opts.ClusterLeaseDuration,
|
||||||
ClusterLeaseRenewIntervalFraction: ctx.Opts.ClusterLeaseRenewIntervalFraction,
|
ClusterLeaseRenewIntervalFraction: ctx.Opts.ClusterLeaseRenewIntervalFraction,
|
||||||
ClusterCacheSyncTimeout: ctx.Opts.ClusterCacheSyncTimeout,
|
ClusterCacheSyncTimeout: ctx.Opts.ClusterCacheSyncTimeout,
|
||||||
|
RateLimiterOptions: ctx.Opts.RateLimiterOptions,
|
||||||
}
|
}
|
||||||
if err := clusterStatusController.SetupWithManager(ctx.Mgr); err != nil {
|
if err := clusterStatusController.SetupWithManager(ctx.Mgr); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -235,6 +237,7 @@ func startExecutionController(ctx controllerscontext.Context) (bool, error) {
|
||||||
PredicateFunc: helper.NewExecutionPredicateOnAgent(),
|
PredicateFunc: helper.NewExecutionPredicateOnAgent(),
|
||||||
InformerManager: informermanager.GetInstance(),
|
InformerManager: informermanager.GetInstance(),
|
||||||
ClusterClientSetFunc: util.NewClusterDynamicClientSetForAgent,
|
ClusterClientSetFunc: util.NewClusterDynamicClientSetForAgent,
|
||||||
|
RatelimiterOptions: ctx.Opts.RateLimiterOptions,
|
||||||
}
|
}
|
||||||
if err := executionController.SetupWithManager(ctx.Mgr); err != nil {
|
if err := executionController.SetupWithManager(ctx.Mgr); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
@ -254,6 +257,7 @@ func startWorkStatusController(ctx controllerscontext.Context) (bool, error) {
|
||||||
ClusterClientSetFunc: util.NewClusterDynamicClientSetForAgent,
|
ClusterClientSetFunc: util.NewClusterDynamicClientSetForAgent,
|
||||||
ClusterCacheSyncTimeout: ctx.Opts.ClusterCacheSyncTimeout,
|
ClusterCacheSyncTimeout: ctx.Opts.ClusterCacheSyncTimeout,
|
||||||
ConcurrentWorkStatusSyncs: ctx.Opts.ConcurrentWorkSyncs,
|
ConcurrentWorkStatusSyncs: ctx.Opts.ConcurrentWorkSyncs,
|
||||||
|
RateLimiterOptions: ctx.Opts.RateLimiterOptions,
|
||||||
}
|
}
|
||||||
workStatusController.RunWorkQueue()
|
workStatusController.RunWorkQueue()
|
||||||
if err := workStatusController.SetupWithManager(ctx.Mgr); err != nil {
|
if err := workStatusController.SetupWithManager(ctx.Mgr); err != nil {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"k8s.io/client-go/tools/leaderelection/resourcelock"
|
"k8s.io/client-go/tools/leaderelection/resourcelock"
|
||||||
componentbaseconfig "k8s.io/component-base/config"
|
componentbaseconfig "k8s.io/component-base/config"
|
||||||
|
|
||||||
|
"github.com/karmada-io/karmada/pkg/sharedcli/ratelimiterflag"
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,6 +62,8 @@ type Options struct {
|
||||||
// ConcurrentWorkSyncs is the number of work objects that are
|
// ConcurrentWorkSyncs is the number of work objects that are
|
||||||
// allowed to sync concurrently.
|
// allowed to sync concurrently.
|
||||||
ConcurrentWorkSyncs int
|
ConcurrentWorkSyncs int
|
||||||
|
|
||||||
|
RateLimiterOpts ratelimiterflag.Options
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOptions builds an default scheduler 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.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.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.")
|
fs.IntVar(&o.ConcurrentWorkSyncs, "concurrent-work-syncs", 5, "The number of Works that are allowed to sync concurrently.")
|
||||||
|
o.RateLimiterOpts.AddFlags(fs)
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,7 @@ func startExecutionController(ctx controllerscontext.Context) (enabled bool, err
|
||||||
PredicateFunc: helper.NewExecutionPredicate(ctx.Mgr),
|
PredicateFunc: helper.NewExecutionPredicate(ctx.Mgr),
|
||||||
InformerManager: informermanager.GetInstance(),
|
InformerManager: informermanager.GetInstance(),
|
||||||
ClusterClientSetFunc: util.NewClusterDynamicClientSet,
|
ClusterClientSetFunc: util.NewClusterDynamicClientSet,
|
||||||
RatelimiterOption: ctx.Opts.RateLimiterOptions,
|
RatelimiterOptions: ctx.Opts.RateLimiterOptions,
|
||||||
}
|
}
|
||||||
if err := executionController.SetupWithManager(ctx.Mgr); err != nil {
|
if err := executionController.SetupWithManager(ctx.Mgr); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|
|
@ -43,7 +43,7 @@ type Controller struct {
|
||||||
PredicateFunc predicate.Predicate
|
PredicateFunc predicate.Predicate
|
||||||
InformerManager informermanager.MultiClusterInformerManager
|
InformerManager informermanager.MultiClusterInformerManager
|
||||||
ClusterClientSetFunc func(clusterName string, client client.Client) (*util.DynamicClusterClient, error)
|
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.
|
// 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(predicate.GenerationChangedPredicate{}).
|
||||||
WithEventFilter(c.PredicateFunc).
|
WithEventFilter(c.PredicateFunc).
|
||||||
WithOptions(controller.Options{
|
WithOptions(controller.Options{
|
||||||
RateLimiter: ratelimiterflag.DefaultControllerRateLimiter(c.RatelimiterOption),
|
RateLimiter: ratelimiterflag.DefaultControllerRateLimiter(c.RatelimiterOptions),
|
||||||
}).
|
}).
|
||||||
Complete(c)
|
Complete(c)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue