add: disable-scheduler-estimator-in-pull-mode flag
Signed-off-by: prodan <pengshihaoren@gmail.com>
This commit is contained in:
parent
03cd025cd1
commit
2f35a48c5e
|
@ -41,6 +41,8 @@ type Options struct {
|
||||||
|
|
||||||
// EnableSchedulerEstimator represents whether the accurate scheduler estimator should be enabled.
|
// EnableSchedulerEstimator represents whether the accurate scheduler estimator should be enabled.
|
||||||
EnableSchedulerEstimator bool
|
EnableSchedulerEstimator bool
|
||||||
|
// DisableSchedulerEstimatorInPullMode represents whether to disable the scheduler estimator in pull mode.
|
||||||
|
DisableSchedulerEstimatorInPullMode bool
|
||||||
// SchedulerEstimatorTimeout specifies the timeout period of calling the accurate scheduler estimator service.
|
// SchedulerEstimatorTimeout specifies the timeout period of calling the accurate scheduler estimator service.
|
||||||
SchedulerEstimatorTimeout metav1.Duration
|
SchedulerEstimatorTimeout metav1.Duration
|
||||||
// SchedulerEstimatorPort is the port that the accurate scheduler estimator server serves at.
|
// SchedulerEstimatorPort is the port that the accurate scheduler estimator server serves at.
|
||||||
|
@ -80,6 +82,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
|
||||||
fs.Float32Var(&o.KubeAPIQPS, "kube-api-qps", 40.0, "QPS to use while talking with karmada-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
|
fs.Float32Var(&o.KubeAPIQPS, "kube-api-qps", 40.0, "QPS to use while talking with karmada-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
|
||||||
fs.IntVar(&o.KubeAPIBurst, "kube-api-burst", 60, "Burst to use while talking with karmada-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
|
fs.IntVar(&o.KubeAPIBurst, "kube-api-burst", 60, "Burst to use while talking with karmada-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
|
||||||
fs.BoolVar(&o.EnableSchedulerEstimator, "enable-scheduler-estimator", false, "Enable calling cluster scheduler estimator for adjusting replicas.")
|
fs.BoolVar(&o.EnableSchedulerEstimator, "enable-scheduler-estimator", false, "Enable calling cluster scheduler estimator for adjusting replicas.")
|
||||||
|
fs.BoolVar(&o.DisableSchedulerEstimatorInPullMode, "disable-scheduler-estimator-in-pull-mode", false, "Disable the scheduler estimator for clusters in pull mode, which takes effect only when enable-scheduler-estimator is true.")
|
||||||
fs.DurationVar(&o.SchedulerEstimatorTimeout.Duration, "scheduler-estimator-timeout", 3*time.Second, "Specifies the timeout period of calling the scheduler estimator service.")
|
fs.DurationVar(&o.SchedulerEstimatorTimeout.Duration, "scheduler-estimator-timeout", 3*time.Second, "Specifies the timeout period of calling the scheduler estimator service.")
|
||||||
fs.IntVar(&o.SchedulerEstimatorPort, "scheduler-estimator-port", defaultEstimatorPort, "The secure port on which to connect the accurate scheduler estimator.")
|
fs.IntVar(&o.SchedulerEstimatorPort, "scheduler-estimator-port", defaultEstimatorPort, "The secure port on which to connect the accurate scheduler estimator.")
|
||||||
fs.BoolVar(&o.EnableEmptyWorkloadPropagation, "enable-empty-workload-propagation", false, "Enable workload with replicas 0 to be propagated to member clusters.")
|
fs.BoolVar(&o.EnableEmptyWorkloadPropagation, "enable-empty-workload-propagation", false, "Enable workload with replicas 0 to be propagated to member clusters.")
|
||||||
|
|
|
@ -115,6 +115,7 @@ func run(opts *options.Options, stopChan <-chan struct{}, registryOptions ...Opt
|
||||||
sched, err := scheduler.NewScheduler(dynamicClientSet, karmadaClient, kubeClientSet,
|
sched, err := scheduler.NewScheduler(dynamicClientSet, karmadaClient, kubeClientSet,
|
||||||
scheduler.WithOutOfTreeRegistry(outOfTreeRegistry),
|
scheduler.WithOutOfTreeRegistry(outOfTreeRegistry),
|
||||||
scheduler.WithEnableSchedulerEstimator(opts.EnableSchedulerEstimator),
|
scheduler.WithEnableSchedulerEstimator(opts.EnableSchedulerEstimator),
|
||||||
|
scheduler.WithDisableSchedulerEstimatorInPullMode(opts.DisableSchedulerEstimatorInPullMode),
|
||||||
scheduler.WithSchedulerEstimatorPort(opts.SchedulerEstimatorPort),
|
scheduler.WithSchedulerEstimatorPort(opts.SchedulerEstimatorPort),
|
||||||
scheduler.WithSchedulerEstimatorTimeout(opts.SchedulerEstimatorTimeout),
|
scheduler.WithSchedulerEstimatorTimeout(opts.SchedulerEstimatorTimeout),
|
||||||
scheduler.WithEnableEmptyWorkloadPropagation(opts.EnableEmptyWorkloadPropagation),
|
scheduler.WithEnableEmptyWorkloadPropagation(opts.EnableEmptyWorkloadPropagation),
|
||||||
|
|
|
@ -80,10 +80,11 @@ type Scheduler struct {
|
||||||
|
|
||||||
eventRecorder record.EventRecorder
|
eventRecorder record.EventRecorder
|
||||||
|
|
||||||
enableSchedulerEstimator bool
|
enableSchedulerEstimator bool
|
||||||
schedulerEstimatorCache *estimatorclient.SchedulerEstimatorCache
|
disableSchedulerEstimatorInPullMode bool
|
||||||
schedulerEstimatorPort int
|
schedulerEstimatorCache *estimatorclient.SchedulerEstimatorCache
|
||||||
schedulerEstimatorWorker util.AsyncWorker
|
schedulerEstimatorPort int
|
||||||
|
schedulerEstimatorWorker util.AsyncWorker
|
||||||
|
|
||||||
enableEmptyWorkloadPropagation bool
|
enableEmptyWorkloadPropagation bool
|
||||||
}
|
}
|
||||||
|
@ -91,6 +92,8 @@ type Scheduler struct {
|
||||||
type schedulerOptions struct {
|
type schedulerOptions struct {
|
||||||
// enableSchedulerEstimator represents whether the accurate scheduler estimator should be enabled.
|
// enableSchedulerEstimator represents whether the accurate scheduler estimator should be enabled.
|
||||||
enableSchedulerEstimator bool
|
enableSchedulerEstimator bool
|
||||||
|
// disableSchedulerEstimatorInPullMode represents whether to disable the scheduler estimator in pull mode.
|
||||||
|
disableSchedulerEstimatorInPullMode bool
|
||||||
// schedulerEstimatorTimeout specifies the timeout period of calling the accurate scheduler estimator service.
|
// schedulerEstimatorTimeout specifies the timeout period of calling the accurate scheduler estimator service.
|
||||||
schedulerEstimatorTimeout metav1.Duration
|
schedulerEstimatorTimeout metav1.Duration
|
||||||
// schedulerEstimatorPort is the port that the accurate scheduler estimator server serves at.
|
// schedulerEstimatorPort is the port that the accurate scheduler estimator server serves at.
|
||||||
|
@ -111,6 +114,13 @@ func WithEnableSchedulerEstimator(enableSchedulerEstimator bool) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithDisableSchedulerEstimatorInPullMode sets the disableSchedulerEstimatorInPullMode for scheduler
|
||||||
|
func WithDisableSchedulerEstimatorInPullMode(disableSchedulerEstimatorInPullMode bool) Option {
|
||||||
|
return func(o *schedulerOptions) {
|
||||||
|
o.disableSchedulerEstimatorInPullMode = disableSchedulerEstimatorInPullMode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithSchedulerEstimatorTimeout sets the schedulerEstimatorTimeout for scheduler
|
// WithSchedulerEstimatorTimeout sets the schedulerEstimatorTimeout for scheduler
|
||||||
func WithSchedulerEstimatorTimeout(schedulerEstimatorTimeout metav1.Duration) Option {
|
func WithSchedulerEstimatorTimeout(schedulerEstimatorTimeout metav1.Duration) Option {
|
||||||
return func(o *schedulerOptions) {
|
return func(o *schedulerOptions) {
|
||||||
|
@ -183,6 +193,7 @@ func NewScheduler(dynamicClient dynamic.Interface, karmadaClient karmadaclientse
|
||||||
|
|
||||||
if options.enableSchedulerEstimator {
|
if options.enableSchedulerEstimator {
|
||||||
sched.enableSchedulerEstimator = options.enableSchedulerEstimator
|
sched.enableSchedulerEstimator = options.enableSchedulerEstimator
|
||||||
|
sched.disableSchedulerEstimatorInPullMode = options.disableSchedulerEstimatorInPullMode
|
||||||
sched.schedulerEstimatorPort = options.schedulerEstimatorPort
|
sched.schedulerEstimatorPort = options.schedulerEstimatorPort
|
||||||
sched.schedulerEstimatorCache = estimatorclient.NewSchedulerEstimatorCache()
|
sched.schedulerEstimatorCache = estimatorclient.NewSchedulerEstimatorCache()
|
||||||
schedulerEstimatorWorkerOptions := util.Options{
|
schedulerEstimatorWorkerOptions := util.Options{
|
||||||
|
@ -575,7 +586,7 @@ func (s *Scheduler) reconcileEstimatorConnection(key util.QueueKey) error {
|
||||||
return fmt.Errorf("failed to reconcile estimator connection as invalid key: %v", key)
|
return fmt.Errorf("failed to reconcile estimator connection as invalid key: %v", key)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := s.clusterLister.Get(name)
|
cluster, err := s.clusterLister.Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
s.schedulerEstimatorCache.DeleteCluster(name)
|
s.schedulerEstimatorCache.DeleteCluster(name)
|
||||||
|
@ -583,6 +594,10 @@ func (s *Scheduler) reconcileEstimatorConnection(key util.QueueKey) error {
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if cluster.Spec.SyncMode == clusterv1alpha1.Pull && s.disableSchedulerEstimatorInPullMode {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return estimatorclient.EstablishConnection(name, s.schedulerEstimatorCache, s.schedulerEstimatorPort)
|
return estimatorclient.EstablishConnection(name, s.schedulerEstimatorCache, s.schedulerEstimatorPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,6 +608,9 @@ func (s *Scheduler) establishEstimatorConnections() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := range clusterList.Items {
|
for i := range clusterList.Items {
|
||||||
|
if clusterList.Items[i].Spec.SyncMode == clusterv1alpha1.Pull && s.disableSchedulerEstimatorInPullMode {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if err = estimatorclient.EstablishConnection(clusterList.Items[i].Name, s.schedulerEstimatorCache, s.schedulerEstimatorPort); err != nil {
|
if err = estimatorclient.EstablishConnection(clusterList.Items[i].Name, s.schedulerEstimatorCache, s.schedulerEstimatorPort); err != nil {
|
||||||
klog.Error(err)
|
klog.Error(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue