Merge pull request #81836 from fabriziopandini/fix-upgrade-checks

kubeadm: fix upgrade checks
This commit is contained in:
Kubernetes Prow Robot 2019-08-26 20:55:37 -07:00 committed by GitHub
commit 533daf6624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -71,7 +71,7 @@ func EnforceVersionPolicies(versionGetter VersionGetter, newK8sVersionStr string
}
// Make sure the new version is a supported version (higher than the minimum one supported)
if constants.MinimumControlPlaneVersion.AtLeast(newK8sVersion) {
if !newK8sVersion.AtLeast(constants.MinimumControlPlaneVersion) {
// This must not happen, kubeadm always supports a minimum version; and we can't go below that
skewErrors.Mandatory = append(skewErrors.Mandatory, errors.Errorf("Specified version to upgrade to %q is equal to or lower than the minimum supported version %q. Please specify a higher version to upgrade to", newK8sVersionStr, clusterVersionStr))
}

View File

@ -191,6 +191,15 @@ func TestEnforceVersionPolicies(t *testing.T) {
newK8sVersion: constants.MinimumControlPlaneVersion.WithPatch(6).String(),
expectedSkippableErrs: 1, // can't upgrade old k8s with newer kubeadm
},
{
name: "build release supported at MinimumControlPlaneVersion",
vg: &fakeVersionGetter{
clusterVersion: constants.MinimumControlPlaneVersion.String(),
kubeletVersion: constants.MinimumControlPlaneVersion.String(),
kubeadmVersion: constants.MinimumControlPlaneVersion.WithBuildeMetadata("build").String(),
},
newK8sVersion: constants.MinimumControlPlaneVersion.WithBuildeMetadata("build").String(),
},
}
for _, rt := range tests {

View File

@ -183,6 +183,14 @@ func (v *Version) WithPreRelease(preRelease string) *Version {
return &result
}
// WithBuildeMetadata returns copy of the version object with requested buildMetadata
func (v *Version) WithBuildeMetadata(buildMetadata string) *Version {
result := *v
result.components = []uint{v.Major(), v.Minor(), v.Patch()}
result.buildMetadata = buildMetadata
return &result
}
// String converts a Version back to a string; note that for versions parsed with
// ParseGeneric, this will not include the trailing uninterpreted portion of the version
// number.