Merge pull request #74212 from rojkov/kubeadm-drop-applyFlags-newK8sVersion

kubeadm: drop applyFlags.newK8sVersion field
pull/564/head
Kubernetes Prow Robot 2019-02-18 10:37:42 -08:00 committed by GitHub
commit 9891824352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 13 deletions

View File

@ -55,7 +55,6 @@ type applyFlags struct {
etcdUpgrade bool etcdUpgrade bool
criSocket string criSocket string
newK8sVersionStr string newK8sVersionStr string
newK8sVersion *version.Version
imagePullTimeout time.Duration imagePullTimeout time.Duration
} }
@ -169,11 +168,10 @@ func runApply(flags *applyFlags) error {
// Use normalized version string in all following code. // Use normalized version string in all following code.
flags.newK8sVersionStr = cfg.KubernetesVersion flags.newK8sVersionStr = cfg.KubernetesVersion
k8sVer, err := version.ParseSemantic(flags.newK8sVersionStr) newK8sVersion, err := version.ParseSemantic(cfg.KubernetesVersion)
if err != nil { if err != nil {
return errors.Errorf("unable to parse normalized version %q as a semantic version", flags.newK8sVersionStr) return errors.Errorf("unable to parse normalized version %q as a semantic version", cfg.KubernetesVersion)
} }
flags.newK8sVersion = k8sVer
if err := features.ValidateVersion(features.InitFeatureGates, cfg.FeatureGates, cfg.KubernetesVersion); err != nil { if err := features.ValidateVersion(features.InitFeatureGates, cfg.FeatureGates, cfg.KubernetesVersion); err != nil {
return err return err
@ -181,7 +179,7 @@ func runApply(flags *applyFlags) error {
// Enforce the version skew policies // Enforce the version skew policies
klog.V(1).Infof("[upgrade/version] enforcing version skew policies") klog.V(1).Infof("[upgrade/version] enforcing version skew policies")
if err := EnforceVersionPolicies(flags, versionGetter); err != nil { if err := EnforceVersionPolicies(newK8sVersion, flags, versionGetter); err != nil {
return errors.Wrap(err, "[upgrade/version] FATAL") return errors.Wrap(err, "[upgrade/version] FATAL")
} }
@ -214,7 +212,7 @@ func runApply(flags *applyFlags) error {
// Upgrade RBAC rules and addons. // Upgrade RBAC rules and addons.
klog.V(1).Infof("[upgrade/postupgrade] upgrading RBAC rules and addons") klog.V(1).Infof("[upgrade/postupgrade] upgrading RBAC rules and addons")
if err := upgrade.PerformPostUpgradeTasks(client, cfg, flags.newK8sVersion, flags.dryRun); err != nil { if err := upgrade.PerformPostUpgradeTasks(client, cfg, newK8sVersion, flags.dryRun); err != nil {
return errors.Wrap(err, "[upgrade/postupgrade] FATAL post-upgrade error") return errors.Wrap(err, "[upgrade/postupgrade] FATAL post-upgrade error")
} }
@ -242,10 +240,10 @@ func SetImplicitFlags(flags *applyFlags) error {
// EnforceVersionPolicies makes sure that the version the user specified is valid to upgrade to // EnforceVersionPolicies makes sure that the version the user specified is valid to upgrade to
// There are both fatal and skippable (with --force) errors // There are both fatal and skippable (with --force) errors
func EnforceVersionPolicies(flags *applyFlags, versionGetter upgrade.VersionGetter) error { func EnforceVersionPolicies(newK8sVersion *version.Version, flags *applyFlags, versionGetter upgrade.VersionGetter) error {
fmt.Printf("[upgrade/version] You have chosen to change the cluster version to %q\n", flags.newK8sVersionStr) fmt.Printf("[upgrade/version] You have chosen to change the cluster version to %q\n", flags.newK8sVersionStr)
versionSkewErrs := upgrade.EnforceVersionPolicies(versionGetter, flags.newK8sVersionStr, flags.newK8sVersion, flags.allowExperimentalUpgrades, flags.allowRCUpgrades) versionSkewErrs := upgrade.EnforceVersionPolicies(versionGetter, flags.newK8sVersionStr, newK8sVersion, flags.allowExperimentalUpgrades, flags.allowRCUpgrades)
if versionSkewErrs != nil { if versionSkewErrs != nil {
if len(versionSkewErrs.Mandatory) > 0 { if len(versionSkewErrs.Mandatory) > 0 {

View File

@ -48,11 +48,6 @@ func TestSetImplicitFlags(t *testing.T) {
t.Run(rt.name, func(t *testing.T) { t.Run(rt.name, func(t *testing.T) {
actualErr := SetImplicitFlags(rt.flags) actualErr := SetImplicitFlags(rt.flags)
// If an error was returned; make newK8sVersion nil so it's easy to match using reflect.DeepEqual later (instead of a random pointer)
if actualErr != nil {
rt.flags.newK8sVersion = nil
}
if !reflect.DeepEqual(*rt.flags, rt.expectedFlags) { if !reflect.DeepEqual(*rt.flags, rt.expectedFlags) {
t.Errorf( t.Errorf(
"failed SetImplicitFlags:\n\texpected flags: %v\n\t actual: %v", "failed SetImplicitFlags:\n\texpected flags: %v\n\t actual: %v",