Skip to content

Commit

Permalink
Restore "auto" version for upgrade cluster (#2464)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbeaumont committed Jul 22, 2020
1 parent 4aeffce commit 565ae97
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pkg/ctl/upgrade/cluster.go
Expand Up @@ -137,7 +137,8 @@ func requiresVersionUpgrade(clusterMeta *api.ClusterMeta, currentEKSVersion stri
}

// If the version was not specified default to the next Kubernetes version and assume the user intended to upgrade if possible
if clusterMeta.Version == "" {
// also support "auto" as version (see #2461)
if clusterMeta.Version == "" || clusterMeta.Version == "auto" {
if api.IsSupportedVersion(nextVersion) {
clusterMeta.Version = nextVersion
return true, nil
Expand All @@ -149,7 +150,7 @@ func requiresVersionUpgrade(clusterMeta *api.ClusterMeta, currentEKSVersion stri
}

if c, err := utils.CompareVersions(clusterMeta.Version, currentEKSVersion); err != nil {
return false, err
return false, errors.Wrap(err, "couldn't compare versions for upgrade")
} else if c < 0 {
return false, fmt.Errorf("cannot upgrade to a lower version. Found given target version %q, current cluster version %q", clusterMeta.Version, currentEKSVersion)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/utils.go
Expand Up @@ -37,7 +37,7 @@ func IsMinVersion(minimumVersion, version string) (bool, error) {
}
targetVersion, err := semver.ParseTolerant(version)
if err != nil {
return false, fmt.Errorf("unable to parse version %s", version)
return false, fmt.Errorf("unable to parse target version %s", version)
}
return targetVersion.GE(minVersion), nil
}
Expand All @@ -49,11 +49,11 @@ func IsMinVersion(minimumVersion, version string) (bool, error) {
func CompareVersions(a, b string) (int, error) {
aVersion, err := semver.ParseTolerant(a)
if err != nil {
return 0, errors.Wrapf(err, "unable to parse version %q", a)
return 0, errors.Wrapf(err, "unable to parse first version %q", a)
}
bVersion, err := semver.ParseTolerant(b)
if err != nil {
return 0, errors.Wrapf(err, "unable to parse version %q", b)
return 0, errors.Wrapf(err, "unable to parse second version %q", b)
}
return aVersion.Compare(bVersion), nil
}

0 comments on commit 565ae97

Please sign in to comment.