mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-20 17:38:50 +00:00
Merge pull request #102745 from ahg-g/ahg-provider
Remove SchedulerAlgorithmSource from scheduler's internal CC API
This commit is contained in:
@@ -98,7 +98,7 @@ type Scheduler struct {
|
||||
type schedulerOptions struct {
|
||||
componentConfigVersion string
|
||||
kubeConfig *restclient.Config
|
||||
schedulerAlgorithmSource schedulerapi.SchedulerAlgorithmSource
|
||||
legacyPolicySource *schedulerapi.SchedulerPolicySource
|
||||
percentageOfNodesToScore int32
|
||||
podInitialBackoffSeconds int64
|
||||
podMaxBackoffSeconds int64
|
||||
@@ -145,10 +145,10 @@ func WithParallelism(threads int32) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithAlgorithmSource sets schedulerAlgorithmSource for Scheduler, the default is a source with DefaultProvider.
|
||||
func WithAlgorithmSource(source schedulerapi.SchedulerAlgorithmSource) Option {
|
||||
// WithPolicySource sets legacy policy config file source.
|
||||
func WithLegacyPolicySource(source *schedulerapi.SchedulerPolicySource) Option {
|
||||
return func(o *schedulerOptions) {
|
||||
o.schedulerAlgorithmSource = source
|
||||
o.legacyPolicySource = source
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,9 +203,6 @@ var defaultSchedulerOptions = schedulerOptions{
|
||||
// Profiles' default plugins are set from the algorithm provider.
|
||||
{SchedulerName: v1.DefaultSchedulerName},
|
||||
},
|
||||
schedulerAlgorithmSource: schedulerapi.SchedulerAlgorithmSource{
|
||||
Provider: defaultAlgorithmSourceProviderName(),
|
||||
},
|
||||
percentageOfNodesToScore: schedulerapi.DefaultPercentageOfNodesToScore,
|
||||
podInitialBackoffSeconds: int64(internalqueue.DefaultPodInitialBackoffDuration.Seconds()),
|
||||
podMaxBackoffSeconds: int64(internalqueue.DefaultPodMaxBackoffDuration.Seconds()),
|
||||
@@ -262,25 +259,23 @@ func New(client clientset.Interface,
|
||||
metrics.Register()
|
||||
|
||||
var sched *Scheduler
|
||||
source := options.schedulerAlgorithmSource
|
||||
switch {
|
||||
case source.Provider != nil:
|
||||
// Create the config from a named algorithm provider.
|
||||
sc, err := configurator.createFromProvider(*source.Provider)
|
||||
if options.legacyPolicySource == nil {
|
||||
sc, err := configurator.createFromConfig()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("couldn't create scheduler using provider %q: %v", *source.Provider, err)
|
||||
return nil, fmt.Errorf("couldn't create scheduler: %v", err)
|
||||
}
|
||||
sched = sc
|
||||
case source.Policy != nil:
|
||||
|
||||
} else {
|
||||
// Create the config from a user specified policy source.
|
||||
policy := &schedulerapi.Policy{}
|
||||
switch {
|
||||
case source.Policy.File != nil:
|
||||
if err := initPolicyFromFile(source.Policy.File.Path, policy); err != nil {
|
||||
case options.legacyPolicySource.File != nil:
|
||||
if err := initPolicyFromFile(options.legacyPolicySource.File.Path, policy); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case source.Policy.ConfigMap != nil:
|
||||
if err := initPolicyFromConfigMap(client, source.Policy.ConfigMap, policy); err != nil {
|
||||
case options.legacyPolicySource.ConfigMap != nil:
|
||||
if err := initPolicyFromConfigMap(client, options.legacyPolicySource.ConfigMap, policy); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -288,14 +283,13 @@ func New(client clientset.Interface,
|
||||
// In this case, c.extenders should be nil since we're using a policy (and therefore not componentconfig,
|
||||
// which would have set extenders in the above instantiation of Configurator from CC options)
|
||||
configurator.extenders = policy.Extenders
|
||||
sc, err := configurator.createFromConfig(*policy)
|
||||
sc, err := configurator.createFromPolicy(*policy)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("couldn't create scheduler from policy: %v", err)
|
||||
}
|
||||
sched = sc
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported algorithm source: %v", source)
|
||||
}
|
||||
|
||||
// Additional tweaks to the config produced by the configurator.
|
||||
sched.StopEverything = stopEverything
|
||||
sched.client = client
|
||||
@@ -700,11 +694,6 @@ func (sched *Scheduler) skipPodSchedule(fwk framework.Framework, pod *v1.Pod) bo
|
||||
return isAssumed
|
||||
}
|
||||
|
||||
func defaultAlgorithmSourceProviderName() *string {
|
||||
provider := schedulerapi.SchedulerDefaultProviderName
|
||||
return &provider
|
||||
}
|
||||
|
||||
// NewInformerFactory creates a SharedInformerFactory and initializes a scheduler specific
|
||||
// in-place podInformer.
|
||||
func NewInformerFactory(cs clientset.Interface, resyncPeriod time.Duration) informers.SharedInformerFactory {
|
||||
|
Reference in New Issue
Block a user