-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kube-scheduler: allow deprecated options to be set with configfile #92531
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,7 +148,13 @@ func newDefaultComponentConfig() (*kubeschedulerconfig.KubeSchedulerConfiguratio | |
// Flags returns flags for a specific scheduler by section name | ||
func (o *Options) Flags() (nfs cliflag.NamedFlagSets) { | ||
fs := nfs.FlagSet("misc") | ||
fs.StringVar(&o.ConfigFile, "config", o.ConfigFile, "The path to the configuration file. Flags override values in this file.") | ||
fs.StringVar(&o.ConfigFile, "config", o.ConfigFile, `The path to the configuration file. The following flags can overwrite fields in this file: | ||
--address | ||
--port | ||
--use-legacy-policy-config | ||
--policy-configmap | ||
--policy-config-file | ||
--algorithm-provider`) | ||
fs.StringVar(&o.WriteConfigTo, "write-config-to", o.WriteConfigTo, "If set, write the configuration values to this file and exit.") | ||
fs.StringVar(&o.Master, "master", o.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig)") | ||
|
||
|
@@ -170,10 +176,8 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error { | |
if len(o.ConfigFile) == 0 { | ||
c.ComponentConfig = o.ComponentConfig | ||
|
||
// only apply deprecated flags if no config file is loaded (this is the old behaviour). | ||
if err := o.Deprecated.ApplyTo(&c.ComponentConfig); err != nil { | ||
return err | ||
} | ||
// apply deprecated flags if no config file is loaded (this is the old behaviour). | ||
o.Deprecated.ApplyTo(&c.ComponentConfig) | ||
if err := o.CombinedInsecureServing.ApplyTo(c, &c.ComponentConfig); err != nil { | ||
return err | ||
} | ||
|
@@ -186,11 +190,18 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error { | |
return err | ||
} | ||
|
||
// use the loaded config file only, with the exception of --address and --port. This means that | ||
// none of the deprecated flags in o.Deprecated are taken into consideration. This is the old | ||
// behaviour of the flags we have to keep. | ||
c.ComponentConfig = *cfg | ||
|
||
// apply any deprecated Policy flags, if applicable | ||
o.Deprecated.ApplyAlgorithmSourceTo(&c.ComponentConfig) | ||
|
||
// if the user has set CC profiles and is trying to use a Policy config, error out | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could call ApplyAlgorithmSourceTo before this and check that .AlgorithmSource.Policy is empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done also note, that we can't check if |
||
// these configs are no longer merged and they should not be used simultaneously | ||
if !emptySchedulerProfileConfig(c.ComponentConfig.Profiles) && c.ComponentConfig.AlgorithmSource.Policy != nil { | ||
return fmt.Errorf("cannot set a Plugin config and Policy config") | ||
} | ||
|
||
// use the loaded config file only, with the exception of --address and --port. | ||
if err := o.CombinedInsecureServing.ApplyToFromLoadedConfig(c, &c.ComponentConfig); err != nil { | ||
return err | ||
} | ||
|
@@ -211,6 +222,15 @@ func (o *Options) ApplyTo(c *schedulerappconfig.Config) error { | |
return nil | ||
} | ||
|
||
// emptySchedulerProfileConfig returns true if the list of profiles passed to it contains only | ||
// the "default-scheduler" profile with no plugins or pluginconfigs registered | ||
// (this is the default empty profile initialized by defaults.go) | ||
func emptySchedulerProfileConfig(profiles []kubeschedulerconfig.KubeSchedulerProfile) bool { | ||
return len(profiles) == 1 && | ||
len(profiles[0].PluginConfig) == 0 && | ||
profiles[0].Plugins == nil | ||
} | ||
|
||
// Validate validates all the required options. | ||
func (o *Options) Validate() []error { | ||
var errs []error | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document in the applicable help strings above that scheduler would fail if the flags are used in combination with scheduling plugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done