Skip to content

Commit 533daf6

Browse files
authored
Merge pull request kubernetes#81836 from fabriziopandini/fix-upgrade-checks
kubeadm: fix upgrade checks
2 parents 90cf189 + 885f81d commit 533daf6

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

cmd/kubeadm/app/phases/upgrade/policy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func EnforceVersionPolicies(versionGetter VersionGetter, newK8sVersionStr string
7171
}
7272

7373
// Make sure the new version is a supported version (higher than the minimum one supported)
74-
if constants.MinimumControlPlaneVersion.AtLeast(newK8sVersion) {
74+
if !newK8sVersion.AtLeast(constants.MinimumControlPlaneVersion) {
7575
// This must not happen, kubeadm always supports a minimum version; and we can't go below that
7676
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))
7777
}

cmd/kubeadm/app/phases/upgrade/policy_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ func TestEnforceVersionPolicies(t *testing.T) {
191191
newK8sVersion: constants.MinimumControlPlaneVersion.WithPatch(6).String(),
192192
expectedSkippableErrs: 1, // can't upgrade old k8s with newer kubeadm
193193
},
194+
{
195+
name: "build release supported at MinimumControlPlaneVersion",
196+
vg: &fakeVersionGetter{
197+
clusterVersion: constants.MinimumControlPlaneVersion.String(),
198+
kubeletVersion: constants.MinimumControlPlaneVersion.String(),
199+
kubeadmVersion: constants.MinimumControlPlaneVersion.WithBuildeMetadata("build").String(),
200+
},
201+
newK8sVersion: constants.MinimumControlPlaneVersion.WithBuildeMetadata("build").String(),
202+
},
194203
}
195204

196205
for _, rt := range tests {

staging/src/k8s.io/apimachinery/pkg/util/version/version.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ func (v *Version) WithPreRelease(preRelease string) *Version {
183183
return &result
184184
}
185185

186+
// WithBuildeMetadata returns copy of the version object with requested buildMetadata
187+
func (v *Version) WithBuildeMetadata(buildMetadata string) *Version {
188+
result := *v
189+
result.components = []uint{v.Major(), v.Minor(), v.Patch()}
190+
result.buildMetadata = buildMetadata
191+
return &result
192+
}
193+
186194
// String converts a Version back to a string; note that for versions parsed with
187195
// ParseGeneric, this will not include the trailing uninterpreted portion of the version
188196
// number.

0 commit comments

Comments
 (0)