-
Notifications
You must be signed in to change notification settings - Fork 558
Make handling Kubernetes versions easier #2506
Make handling Kubernetes versions easier #2506
Conversation
fb7b169
to
a248dd4
Compare
so we don’t have to define version whitelist twice
@@ -53,120 +57,48 @@ const ( | |||
) | |||
|
|||
const ( | |||
// KubernetesVersion1Dot10Dot0RC1 is the string for kubernetes 1.10.0-rc.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These consts were not adding to readability/maintainability, and runtime optimization is not a concern
pkg/api/common/const.go
Outdated
KubernetesVersion1Dot10Dot0RC1: false, | ||
var AllKubernetesWindowsSupportedVersions = getAllKubernetesWindowsSupportedVersionsMap() | ||
|
||
func getAllKubernetesWindowsSupportedVersionsMap() map[string]bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of Windows support being a mostly duplicated whitelist of the larger support matrix, this is now an override/blackslist
pkg/api/common/helper_test.go
Outdated
t.Errorf("It is not the default Kubernetes version") | ||
} | ||
|
||
version = GetValidPatchVersion(Kubernetes, "1.6.3") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these static tests tied to most recent patch versions were suggesting that there was some significance to testing the most recent patch version in these unit tests. In fact this unit test should be maintained independently of kubernets release version particulars.
pkg/api/common/helper_test.go
Outdated
if v != version { | ||
t.Errorf("Expected version %s, instead got version %s", version, v) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func TestGetLatestPatchVersion(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto above
pkg/api/common/helper_test.go
Outdated
@@ -78,39 +46,31 @@ func Test_RationalizeReleaseAndVersion(t *testing.T) { | |||
t.Errorf("It is not the default Kubernetes version") | |||
} | |||
|
|||
latest1Dot6Version := GetLatestPatchVersion("1.6", GetAllSupportedKubernetesVersions()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have conveniences to grab the latest version in a major.minor release channel, so we don't need to be maintaining them statically to validate "orchestratorRelease" behavior.
if o.OrchestratorVersion == common.KubernetesVersion1Dot6Dot6 || | ||
o.OrchestratorVersion == common.KubernetesVersion1Dot6Dot9 || | ||
o.OrchestratorVersion == common.KubernetesVersion1Dot6Dot11 { | ||
sv, _ := semver.NewVersion(o.OrchestratorVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually validating what our error condition suggests we're validating. :)
if o.OrchestratorVersion == common.KubernetesVersion1Dot6Dot6 || | ||
o.OrchestratorVersion == common.KubernetesVersion1Dot6Dot9 || | ||
o.OrchestratorVersion == common.KubernetesVersion1Dot6Dot11 { | ||
sv, _ := semver.NewVersion(o.OrchestratorVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot12 || | ||
o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot13 || | ||
o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot14 { | ||
sv, _ := semver.NewVersion(o.OrchestratorVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
@@ -235,22 +224,6 @@ func (o *OrchestratorVersionProfile) Validate() error { | |||
return o.OrchestratorProfile.Validate(false) | |||
} | |||
|
|||
// ValidateForUpgrade validates upgrade input data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is never referenced.
@@ -259,10 +259,7 @@ func Test_KubernetesConfig_Validate(t *testing.T) { | |||
} | |||
|
|||
// Tests that apply to 1.6 and later releases | |||
for _, k8sVersion := range []string{common.KubernetesVersion1Dot6Dot11, common.KubernetesVersion1Dot6Dot12, common.KubernetesVersion1Dot6Dot13, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't believe we've been maintaining this string slice literal
@@ -274,7 +271,7 @@ func Test_KubernetesConfig_Validate(t *testing.T) { | |||
|
|||
trueVal := true | |||
// Tests that apply to 1.8 and later releases | |||
for _, k8sVersion := range []string{common.KubernetesVersion1Dot8Dot1} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes we were never doing what we said
Is there any way to make this go away? (and the other 2 const checks) acs-engine/pkg/api/orchestrators_test.go Line 129 in 79f6515
(I know I'm asking for extra credit, your PR is already great as-is) |
pkg/api/common/versions.go
Outdated
if cons.Check(sv) { | ||
ret = append(ret, v) | ||
} | ||
} | ||
return ret | ||
} | ||
|
||
// GetVersionsLt returns a list of versions greater than a semver string given a list of versions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it just me or should this function be called GetVersionsGt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scratch that, the comment should be returns a list of versions lesser than a semver string
|
||
// v20170930 - kubernetes only | ||
list, e = GetOrchestratorVersionProfileListV20170930(common.Kubernetes, "") | ||
Expect(e).To(BeNil()) | ||
Expect(len(list.Properties.Orchestrators)).To(Equal(36)) | ||
Expect(len(list.Properties.Orchestrators)).To(Equal(len(common.GetAllSupportedKubernetesVersions()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
|
||
// 1.10.0-rc.1 is not upgradable | ||
// The latest version is not upgradable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
What this PR does / why we need it: Expands version generics and gets rid of static consts so we can more fluidly and easily evolve w/ newer Kubernetes versions going forward.
This PR will mean that to add support for future Kubernetes versions we maintain a single map (
AllKubernetesSupportedVersions
inpkg/api/common
)Release note: