mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
kubeadm: remove the limitation that the 'ignorePreflightErrors' field can not be set to 'all' in kubeadm config file, and keep CLI / config consistent
This commit is contained in:
parent
900237fada
commit
bd9b78d686
@ -221,7 +221,8 @@ type NodeRegistrationOptions struct {
|
|||||||
// command line except without leading dash(es).
|
// command line except without leading dash(es).
|
||||||
KubeletExtraArgs map[string]string
|
KubeletExtraArgs map[string]string
|
||||||
|
|
||||||
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored when the current node is registered.
|
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored when the current node is registered, e.g. 'IsPrivilegedUser,Swap'.
|
||||||
|
// Value 'all' ignores errors from all checks.
|
||||||
IgnorePreflightErrors []string
|
IgnorePreflightErrors []string
|
||||||
|
|
||||||
// ImagePullPolicy specifies the policy for image pulling during kubeadm "init" and "join" operations.
|
// ImagePullPolicy specifies the policy for image pulling during kubeadm "init" and "join" operations.
|
||||||
@ -488,6 +489,7 @@ type ResetConfiguration struct {
|
|||||||
Force bool
|
Force bool
|
||||||
|
|
||||||
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored during the reset process, e.g. 'IsPrivilegedUser,Swap'.
|
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored during the reset process, e.g. 'IsPrivilegedUser,Swap'.
|
||||||
|
// Value 'all' ignores errors from all checks.
|
||||||
IgnorePreflightErrors []string
|
IgnorePreflightErrors []string
|
||||||
|
|
||||||
// SkipPhases is a list of phases to skip during command execution.
|
// SkipPhases is a list of phases to skip during command execution.
|
||||||
|
@ -228,7 +228,8 @@ type NodeRegistrationOptions struct {
|
|||||||
// +optional
|
// +optional
|
||||||
KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"`
|
KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"`
|
||||||
|
|
||||||
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored when the current node is registered.
|
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored when the current node is registered, e.g. 'IsPrivilegedUser,Swap'.
|
||||||
|
// Value 'all' ignores errors from all checks.
|
||||||
// +optional
|
// +optional
|
||||||
IgnorePreflightErrors []string `json:"ignorePreflightErrors,omitempty"`
|
IgnorePreflightErrors []string `json:"ignorePreflightErrors,omitempty"`
|
||||||
|
|
||||||
|
@ -233,7 +233,8 @@ type NodeRegistrationOptions struct {
|
|||||||
// +optional
|
// +optional
|
||||||
KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"`
|
KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"`
|
||||||
|
|
||||||
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored when the current node is registered.
|
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored when the current node is registered, e.g. 'IsPrivilegedUser,Swap'.
|
||||||
|
// Value 'all' ignores errors from all checks.
|
||||||
// +optional
|
// +optional
|
||||||
IgnorePreflightErrors []string `json:"ignorePreflightErrors,omitempty"`
|
IgnorePreflightErrors []string `json:"ignorePreflightErrors,omitempty"`
|
||||||
|
|
||||||
@ -482,6 +483,7 @@ type ResetConfiguration struct {
|
|||||||
Force bool `json:"force,omitempty"`
|
Force bool `json:"force,omitempty"`
|
||||||
|
|
||||||
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored during the reset process, e.g. 'IsPrivilegedUser,Swap'.
|
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored during the reset process, e.g. 'IsPrivilegedUser,Swap'.
|
||||||
|
// Value 'all' ignores errors from all checks.
|
||||||
// +optional
|
// +optional
|
||||||
IgnorePreflightErrors []string `json:"ignorePreflightErrors,omitempty"`
|
IgnorePreflightErrors []string `json:"ignorePreflightErrors,omitempty"`
|
||||||
|
|
||||||
|
@ -605,13 +605,6 @@ func ValidateIgnorePreflightErrors(ignorePreflightErrorsFromCLI, ignorePreflight
|
|||||||
ignoreErrors.Insert(strings.ToLower(item)) // parameters are case insensitive
|
ignoreErrors.Insert(strings.ToLower(item)) // parameters are case insensitive
|
||||||
}
|
}
|
||||||
|
|
||||||
if ignoreErrors.Has("all") {
|
|
||||||
// "all" is forbidden in config files. Administrators should use an
|
|
||||||
// explicit list of errors they want to ignore, as it can be risky to
|
|
||||||
// mask all errors in such a way. Hence, we return an error:
|
|
||||||
allErrs = append(allErrs, field.Invalid(field.NewPath("ignorePreflightErrors"), "all", "'all' cannot be used in configuration file"))
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, item := range ignorePreflightErrorsFromCLI {
|
for _, item := range ignorePreflightErrorsFromCLI {
|
||||||
ignoreErrors.Insert(strings.ToLower(item)) // parameters are case insensitive
|
ignoreErrors.Insert(strings.ToLower(item)) // parameters are case insensitive
|
||||||
}
|
}
|
||||||
|
@ -794,19 +794,37 @@ func TestValidateIgnorePreflightErrors(t *testing.T) {
|
|||||||
sets.New("a", "b", "c"),
|
sets.New("a", "b", "c"),
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
{ // empty list in CLI, but 'all' present in config file
|
||||||
|
[]string{},
|
||||||
|
[]string{"all"},
|
||||||
|
sets.New("all"),
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{ // empty list in config file, but 'all' present in CLI
|
||||||
|
[]string{"all"},
|
||||||
|
[]string{},
|
||||||
|
sets.New("all"),
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{ // some duplicates, only 'all' present in CLI and config file
|
||||||
|
[]string{"all"},
|
||||||
|
[]string{"all"},
|
||||||
|
sets.New("all"),
|
||||||
|
false,
|
||||||
|
},
|
||||||
{ // non-duplicate, but 'all' present together with individual checks in CLI
|
{ // non-duplicate, but 'all' present together with individual checks in CLI
|
||||||
[]string{"a", "b", "all"},
|
[]string{"a", "b", "all"},
|
||||||
[]string{},
|
[]string{},
|
||||||
sets.New[string](),
|
sets.New[string](),
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{ // empty list in CLI, but 'all' present in config file, which is forbidden
|
{ // non-duplicate, but 'all' present together with individual checks in config file
|
||||||
[]string{},
|
[]string{},
|
||||||
[]string{"all"},
|
[]string{"a", "b", "all"},
|
||||||
sets.New[string](),
|
sets.New[string](),
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{ // non-duplicate, but 'all' present in config file, which is forbidden
|
{ // non-duplicate, but 'all' present in config file, while values are in CLI, which is forbidden
|
||||||
[]string{"a", "b"},
|
[]string{"a", "b"},
|
||||||
[]string{"all"},
|
[]string{"all"},
|
||||||
sets.New[string](),
|
sets.New[string](),
|
||||||
@ -818,12 +836,6 @@ func TestValidateIgnorePreflightErrors(t *testing.T) {
|
|||||||
sets.New[string](),
|
sets.New[string](),
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{ // skip all checks
|
|
||||||
[]string{"all"},
|
|
||||||
[]string{},
|
|
||||||
sets.New("all"),
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
for _, rt := range tests {
|
for _, rt := range tests {
|
||||||
result, err := ValidateIgnorePreflightErrors(rt.ignorePreflightErrorsFromCLI, rt.ignorePreflightErrorsFromConfigFile)
|
result, err := ValidateIgnorePreflightErrors(rt.ignorePreflightErrorsFromCLI, rt.ignorePreflightErrorsFromConfigFile)
|
||||||
|
Loading…
Reference in New Issue
Block a user