Make parallelism as part of schedulerOptions

This commit is contained in:
drfish
2021-03-01 22:20:18 +08:00
parent bc13a38367
commit c2ceb21a3e
21 changed files with 149 additions and 107 deletions

View File

@@ -98,6 +98,7 @@ type schedulerOptions struct {
profiles []schedulerapi.KubeSchedulerProfile
extenders []schedulerapi.Extender
frameworkCapturer FrameworkCapturer
parallelism int32
}
// Option configures a Scheduler
@@ -112,10 +113,9 @@ func WithProfiles(p ...schedulerapi.KubeSchedulerProfile) Option {
}
// WithParallelism sets the parallelism for all scheduler algorithms. Default is 16.
// TODO(#95952): Remove global setter in favor of a struct that holds the configuration.
func WithParallelism(threads int32) Option {
return func(o *schedulerOptions) {
parallelize.SetParallelism(int(threads))
o.parallelism = threads
}
}
@@ -183,6 +183,7 @@ var defaultSchedulerOptions = schedulerOptions{
percentageOfNodesToScore: schedulerapi.DefaultPercentageOfNodesToScore,
podInitialBackoffSeconds: int64(internalqueue.DefaultPodInitialBackoffDuration.Seconds()),
podMaxBackoffSeconds: int64(internalqueue.DefaultPodMaxBackoffDuration.Seconds()),
parallelism: int32(parallelize.DefaultParallelism),
}
// New returns a Scheduler
@@ -225,6 +226,7 @@ func New(client clientset.Interface,
nodeInfoSnapshot: snapshot,
extenders: options.extenders,
frameworkCapturer: options.frameworkCapturer,
parallellism: options.parallelism,
}
metrics.Register()