mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-18 07:34:12 +00:00
Remove SchedulerAlgorithmSource from scheduler's internal CC API
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
schedulerappconfig "k8s.io/kubernetes/cmd/kube-scheduler/app/config"
|
||||
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config/validation"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/interpodaffinity"
|
||||
@@ -84,48 +85,44 @@ func (o *DeprecatedOptions) Validate() []error {
|
||||
return errs
|
||||
}
|
||||
|
||||
// ApplyAlgorithmSourceTo sets cfg.AlgorithmSource from flags passed on the command line in the following precedence order:
|
||||
// ApplyPolicySourceTo sets cfg.PolicySource from flags passed on the command line in the following precedence order:
|
||||
//
|
||||
// 1. --use-legacy-policy-config to use a policy file.
|
||||
// 2. --policy-configmap to use a policy config map value.
|
||||
func (o *DeprecatedOptions) ApplyAlgorithmSourceTo(cfg *kubeschedulerconfig.KubeSchedulerConfiguration) {
|
||||
func (o *DeprecatedOptions) ApplyPolicySourceTo(c *schedulerappconfig.Config) {
|
||||
if o == nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch {
|
||||
case o.UseLegacyPolicyConfig || (len(o.PolicyConfigFile) > 0 && o.PolicyConfigMapName == ""):
|
||||
cfg.AlgorithmSource = kubeschedulerconfig.SchedulerAlgorithmSource{
|
||||
Policy: &kubeschedulerconfig.SchedulerPolicySource{
|
||||
File: &kubeschedulerconfig.SchedulerPolicyFileSource{
|
||||
Path: o.PolicyConfigFile,
|
||||
},
|
||||
c.LegacyPolicySource = &kubeschedulerconfig.SchedulerPolicySource{
|
||||
File: &kubeschedulerconfig.SchedulerPolicyFileSource{
|
||||
Path: o.PolicyConfigFile,
|
||||
},
|
||||
}
|
||||
case len(o.PolicyConfigMapName) > 0:
|
||||
cfg.AlgorithmSource = kubeschedulerconfig.SchedulerAlgorithmSource{
|
||||
Policy: &kubeschedulerconfig.SchedulerPolicySource{
|
||||
ConfigMap: &kubeschedulerconfig.SchedulerPolicyConfigMapSource{
|
||||
Name: o.PolicyConfigMapName,
|
||||
Namespace: o.PolicyConfigMapNamespace,
|
||||
},
|
||||
c.LegacyPolicySource = &kubeschedulerconfig.SchedulerPolicySource{
|
||||
ConfigMap: &kubeschedulerconfig.SchedulerPolicyConfigMapSource{
|
||||
Name: o.PolicyConfigMapName,
|
||||
Namespace: o.PolicyConfigMapNamespace,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ApplyTo sets a default profile plugin config if no config file is specified
|
||||
// It also calls ApplyAlgorithmSourceTo to set Policy settings in AlgorithmSource, if applicable.
|
||||
// It also calls ApplyPolicySourceTo to set Policy source if applicable.
|
||||
// Deprecated flags have an effect iff no config file was provided, in which
|
||||
// case this function expects a default KubeSchedulerConfiguration instance,
|
||||
// which has a single profile.
|
||||
func (o *DeprecatedOptions) ApplyTo(cfg *kubeschedulerconfig.KubeSchedulerConfiguration) {
|
||||
func (o *DeprecatedOptions) ApplyTo(c *schedulerappconfig.Config) {
|
||||
if o == nil {
|
||||
return
|
||||
}
|
||||
// The following deprecated options affect the only existing profile that is
|
||||
// added by default.
|
||||
profile := &cfg.Profiles[0]
|
||||
profile := &c.ComponentConfig.Profiles[0]
|
||||
if len(o.SchedulerName) > 0 {
|
||||
profile.SchedulerName = o.SchedulerName
|
||||
}
|
||||
@@ -137,5 +134,5 @@ func (o *DeprecatedOptions) ApplyTo(cfg *kubeschedulerconfig.KubeSchedulerConfig
|
||||
}
|
||||
|
||||
profile.PluginConfig = append(profile.PluginConfig, plCfg)
|
||||
o.ApplyAlgorithmSourceTo(cfg)
|
||||
o.ApplyPolicySourceTo(c)
|
||||
}
|
||||
|
@@ -179,7 +179,7 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
|
||||
c.ComponentConfig = o.ComponentConfig
|
||||
|
||||
// apply deprecated flags if no config file is loaded (this is the old behaviour).
|
||||
o.Deprecated.ApplyTo(&c.ComponentConfig)
|
||||
o.Deprecated.ApplyTo(c)
|
||||
if err := o.CombinedInsecureServing.ApplyTo(c, &c.ComponentConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -195,11 +195,11 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error {
|
||||
c.ComponentConfig = *cfg
|
||||
|
||||
// apply any deprecated Policy flags, if applicable
|
||||
o.Deprecated.ApplyAlgorithmSourceTo(&c.ComponentConfig)
|
||||
o.Deprecated.ApplyPolicySourceTo(c)
|
||||
|
||||
// if the user has set CC profiles and is trying to use a Policy config, error out
|
||||
// these configs are no longer merged and they should not be used simultaneously
|
||||
if !emptySchedulerProfileConfig(c.ComponentConfig.Profiles) && c.ComponentConfig.AlgorithmSource.Policy != nil {
|
||||
if !emptySchedulerProfileConfig(c.ComponentConfig.Profiles) && c.LegacyPolicySource != nil {
|
||||
return fmt.Errorf("cannot set a Plugin config and Policy config")
|
||||
}
|
||||
|
||||
|
@@ -330,7 +330,6 @@ profiles:
|
||||
defer os.Setenv("KUBERNETES_SERVICE_HOST", originalHost)
|
||||
}
|
||||
|
||||
defaultSource := "DefaultProvider"
|
||||
defaultPodInitialBackoffSeconds := int64(1)
|
||||
defaultPodMaxBackoffSeconds := int64(10)
|
||||
defaultPercentageOfNodesToScore := int32(0)
|
||||
@@ -386,7 +385,6 @@ profiles:
|
||||
APIVersion: v1beta2.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
|
||||
HealthzBindAddress: "0.0.0.0:10251",
|
||||
MetricsBindAddress: "0.0.0.0:10251",
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
@@ -459,7 +457,6 @@ profiles:
|
||||
APIVersion: v1beta1.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
|
||||
HealthzBindAddress: "0.0.0.0:10251",
|
||||
MetricsBindAddress: "0.0.0.0:10251",
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
@@ -560,7 +557,6 @@ profiles:
|
||||
APIVersion: v1beta2.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
|
||||
HealthzBindAddress: "", // defaults empty when not running from config file
|
||||
MetricsBindAddress: "", // defaults empty when not running from config file
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
@@ -629,7 +625,6 @@ profiles:
|
||||
APIVersion: v1beta2.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
|
||||
HealthzBindAddress: "", // defaults empty when not running from config file
|
||||
MetricsBindAddress: "", // defaults empty when not running from config file
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
@@ -672,7 +667,6 @@ profiles:
|
||||
APIVersion: v1beta2.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
|
||||
HealthzBindAddress: "0.0.0.0:10251",
|
||||
MetricsBindAddress: "0.0.0.0:10251",
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
@@ -750,7 +744,6 @@ profiles:
|
||||
APIVersion: v1beta1.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
|
||||
HealthzBindAddress: "0.0.0.0:10251",
|
||||
MetricsBindAddress: "0.0.0.0:10251",
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
@@ -829,7 +822,6 @@ profiles:
|
||||
APIVersion: v1beta2.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
|
||||
HealthzBindAddress: "0.0.0.0:10251",
|
||||
MetricsBindAddress: "0.0.0.0:10251",
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
@@ -895,7 +887,6 @@ profiles:
|
||||
APIVersion: v1beta1.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
|
||||
HealthzBindAddress: "0.0.0.0:10251",
|
||||
MetricsBindAddress: "0.0.0.0:10251",
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
@@ -974,8 +965,7 @@ profiles:
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: v1beta2.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
|
||||
Parallelism: 16,
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
EnableProfiling: true,
|
||||
EnableContentionProfiling: true,
|
||||
@@ -1030,8 +1020,7 @@ profiles:
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: v1beta2.SchemeGroupVersion.String(),
|
||||
},
|
||||
Parallelism: 16,
|
||||
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
|
||||
Parallelism: 16,
|
||||
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
|
||||
EnableProfiling: true,
|
||||
EnableContentionProfiling: true,
|
||||
|
Reference in New Issue
Block a user