From 5854b92450d0ff73ff7a0f16ea9f681c30853e6f Mon Sep 17 00:00:00 2001 From: Dave Chen Date: Wed, 26 Oct 2022 16:05:28 +0800 Subject: [PATCH] kubeadm: Don't reuse the `ignorePreflightErrors` from initCfg for `reset` The init config file fetched from cluster won't have `ignorePreflightErrors` set, and shouldn't try to reuse it even it's set with any value. Instead, it should be defined in reset config file and fetch from it when the reset config is ready. Signed-off-by: Dave Chen --- cmd/kubeadm/app/cmd/reset.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cmd/kubeadm/app/cmd/reset.go b/cmd/kubeadm/app/cmd/reset.go index 4e6a656a405..724e57e205e 100644 --- a/cmd/kubeadm/app/cmd/reset.go +++ b/cmd/kubeadm/app/cmd/reset.go @@ -109,7 +109,8 @@ func newResetData(cmd *cobra.Command, options *resetOptions, in io.Reader, out i klog.V(1).Infof("[reset] Could not obtain a client set from the kubeconfig file: %s", options.kubeconfigPath) } - ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(options.ignorePreflightErrors, ignorePreflightErrors(cfg)) + ignorePreflightErrorsFromCfg := []string{} + ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(options.ignorePreflightErrors, ignorePreflightErrorsFromCfg) if err != nil { return nil, err } @@ -144,13 +145,6 @@ func newResetData(cmd *cobra.Command, options *resetOptions, in io.Reader, out i }, nil } -func ignorePreflightErrors(cfg *kubeadmapi.InitConfiguration) []string { - if cfg == nil { - return []string{} - } - return cfg.NodeRegistration.IgnorePreflightErrors -} - // AddResetFlags adds reset flags func AddResetFlags(flagSet *flag.FlagSet, resetOptions *resetOptions) { flagSet.StringVar(