diff --git a/cmd/kubeadm/app/cmd/upgrade/common.go b/cmd/kubeadm/app/cmd/upgrade/common.go index 8e02e0d4c6c..4a46e1b789e 100644 --- a/cmd/kubeadm/app/cmd/upgrade/common.go +++ b/cmd/kubeadm/app/cmd/upgrade/common.go @@ -163,24 +163,6 @@ func enforceRequirements(flags *applyPlanFlags, args []string, dryRun bool, upgr newK8sVersion = cfg.KubernetesVersion } - ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(flags.ignorePreflightErrors, cfg.NodeRegistration.IgnorePreflightErrors) - if err != nil { - return nil, nil, nil, err - } - // Also set the union of pre-flight errors to InitConfiguration, to provide a consistent view of the runtime configuration: - cfg.NodeRegistration.IgnorePreflightErrors = ignorePreflightErrorsSet.List() - - // Ensure the user is root - klog.V(1).Info("running preflight checks") - if err := runPreflightChecks(client, ignorePreflightErrorsSet, &cfg.ClusterConfiguration, printer); err != nil { - return nil, nil, nil, err - } - - // Run healthchecks against the cluster - if err := upgrade.CheckClusterHealth(client, &cfg.ClusterConfiguration, ignorePreflightErrorsSet); err != nil { - return nil, nil, nil, errors.Wrap(err, "[upgrade/health] FATAL") - } - // The version arg is mandatory, during upgrade apply, unless it's specified in the config file if upgradeApply && newK8sVersion == "" { if err := cmdutil.ValidateExactArgNumber(args, []string{"version"}); err != nil { @@ -202,6 +184,24 @@ func enforceRequirements(flags *applyPlanFlags, args []string, dryRun bool, upgr } } + ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(flags.ignorePreflightErrors, cfg.NodeRegistration.IgnorePreflightErrors) + if err != nil { + return nil, nil, nil, err + } + // Also set the union of pre-flight errors to InitConfiguration, to provide a consistent view of the runtime configuration: + cfg.NodeRegistration.IgnorePreflightErrors = ignorePreflightErrorsSet.List() + + // Ensure the user is root + klog.V(1).Info("running preflight checks") + if err := runPreflightChecks(client, ignorePreflightErrorsSet, &cfg.ClusterConfiguration, printer); err != nil { + return nil, nil, nil, err + } + + // Run healthchecks against the cluster + if err := upgrade.CheckClusterHealth(client, &cfg.ClusterConfiguration, ignorePreflightErrorsSet); err != nil { + return nil, nil, nil, errors.Wrap(err, "[upgrade/health] FATAL") + } + // If features gates are passed to the command line, use it (otherwise use featureGates from configuration) if flags.featureGatesString != "" { cfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, flags.featureGatesString) diff --git a/cmd/kubeadm/app/phases/upgrade/health.go b/cmd/kubeadm/app/phases/upgrade/health.go index 55acdf865a6..79d3c379237 100644 --- a/cmd/kubeadm/app/phases/upgrade/health.go +++ b/cmd/kubeadm/app/phases/upgrade/health.go @@ -65,7 +65,6 @@ func (c *healthCheck) Name() string { // CheckClusterHealth makes sure: // - the API /healthz endpoint is healthy // - all control-plane Nodes are Ready -// - (if self-hosted) that there are DaemonSets with at least one Pod for all control plane components // - (if static pod-hosted) that all required Static Pod manifests exist on disk func CheckClusterHealth(client clientset.Interface, cfg *kubeadmapi.ClusterConfiguration, ignoreChecksErrors sets.String) error { fmt.Println("[upgrade] Running cluster health checks")