Skip to content

Commit d902351

Browse files
authored
Merge pull request kubernetes#125797 from SataQiu/fix-upgrade-20240629
kubeadm: the '--feature-gates' flag is deprecated and no-op for 'kubeadm upgrade apply/plan'
2 parents a7264f9 + d9001c7 commit d902351

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

cmd/kubeadm/app/apis/kubeadm/validation/validation.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,9 @@ func isAllowedFlag(flagName string) bool {
609609
kubeadmcmdoptions.NodeName,
610610
kubeadmcmdoptions.KubeconfigDir,
611611
kubeadmcmdoptions.UploadCerts,
612+
kubeadmcmdoptions.FeatureGatesString, // TODO: remove this line when --feature-gates flag is deprecated and dropped from "kubeadm upgrade apply/plan"
612613
"api-server-manifest", "controller-manager-manifest", "scheduler-manifest", // TODO: remove this line when these flags are deprecated and dropped from "kubeadm upgrade diff"
614+
"allow-missing-template-keys", "output", "show-managed-fields",
613615
"print-join-command", "rootfs", "v", "log-file", "yes")
614616
if allowedFlags.Has(flagName) {
615617
return true

cmd/kubeadm/app/cmd/upgrade/common.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,6 @@ func enforceRequirements(flagSet *pflag.FlagSet, flags *applyPlanFlags, args []s
143143
return nil, nil, nil, nil, errors.Wrap(err, "[upgrade/health] FATAL")
144144
}
145145

146-
// If features gates are passed to the command line, use it (otherwise use featureGates from configuration)
147-
if flags.featureGatesString != "" {
148-
initCfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, flags.featureGatesString)
149-
if err != nil {
150-
return nil, nil, nil, nil, errors.Wrap(err, "[upgrade/config] FATAL")
151-
}
152-
}
153-
154146
// Check if feature gate flags used in the cluster are consistent with the set of features currently supported by kubeadm
155147
if msg := features.CheckDeprecatedFlags(&features.InitFeatureGates, initCfg.FeatureGates); len(msg) > 0 {
156148
for _, m := range msg {

cmd/kubeadm/app/cmd/upgrade/upgrade.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ limitations under the License.
1717
package upgrade
1818

1919
import (
20+
"fmt"
2021
"io"
2122

2223
"github.com/spf13/cobra"
2324
"github.com/spf13/pflag"
2425

26+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2527
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
2628
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
2729
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
@@ -71,6 +73,8 @@ func addApplyPlanFlags(fs *pflag.FlagSet, flags *applyPlanFlags) {
7173
fs.BoolVar(&flags.allowExperimentalUpgrades, "allow-experimental-upgrades", flags.allowExperimentalUpgrades, "Show unstable versions of Kubernetes as an upgrade alternative and allow upgrading to an alpha/beta/release candidate versions of Kubernetes.")
7274
fs.BoolVar(&flags.allowRCUpgrades, "allow-release-candidate-upgrades", flags.allowRCUpgrades, "Show release candidate versions of Kubernetes as an upgrade alternative and allow upgrading to a release candidate versions of Kubernetes.")
7375
fs.BoolVar(&flags.printConfig, "print-config", flags.printConfig, "Specifies whether the configuration file that will be used in the upgrade should be printed or not.")
74-
options.AddFeatureGatesStringFlag(fs, &flags.featureGatesString)
76+
options.AddFeatureGatesStringFlag(fs, &flags.featureGatesString) // TODO: remove in 1.32
77+
_ = fs.MarkDeprecated(options.FeatureGatesString, fmt.Sprintf("This flag is deprecated and no-op now. It will be removed in a future release. The upgrade workflow is not designed to reconfigure the cluster. "+
78+
"Please edit the 'featureGates' field of ClusterConfiguration which is defined in the %s/%s ConfigMap instead.", metav1.NamespaceSystem, kubeadmconstants.KubeadmConfigConfigMap))
7579
options.AddIgnorePreflightErrorsFlag(fs, &flags.ignorePreflightErrors)
7680
}

0 commit comments

Comments
 (0)