From a04cc020f1b3992fcf185ef2b1bf12c55815fb5a Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Tue, 23 Apr 2024 10:27:40 +0300 Subject: [PATCH] kubeadm: make sure we only track >= 3 etcd versions at at time There is no point to track more than 3 etcd versions at a time where each etcd versions maps to a k8s CP version. It's 3 instead of 2 (k8s CP / kubeadm version skew size) because there is a period of time where the 3rd version (newest) will be WIP at k/k master - e.g. at the time of this commit it's 1.31. Add a unit test to block on this. Also fixate the min etcd version to 3.5.11. --- cmd/kubeadm/app/constants/constants.go | 9 +-------- cmd/kubeadm/app/constants/constants_test.go | 12 ++++++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cmd/kubeadm/app/constants/constants.go b/cmd/kubeadm/app/constants/constants.go index c93f553fd89..35dd4455426 100644 --- a/cmd/kubeadm/app/constants/constants.go +++ b/cmd/kubeadm/app/constants/constants.go @@ -317,7 +317,7 @@ const ( KubeletHealthzPort = 10248 // MinExternalEtcdVersion indicates minimum external etcd version which kubeadm supports - MinExternalEtcdVersion = "3.4.13-4" + MinExternalEtcdVersion = "3.5.11-0" // DefaultEtcdVersion indicates the default etcd version that kubeadm uses DefaultEtcdVersion = "3.5.13-0" @@ -479,13 +479,6 @@ var ( // SupportedEtcdVersion lists officially supported etcd versions with corresponding Kubernetes releases SupportedEtcdVersion = map[uint8]string{ - 22: "3.5.13-0", - 23: "3.5.13-0", - 24: "3.5.13-0", - 25: "3.5.13-0", - 26: "3.5.13-0", - 27: "3.5.13-0", - 28: "3.5.13-0", 29: "3.5.13-0", 30: "3.5.13-0", 31: "3.5.13-0", diff --git a/cmd/kubeadm/app/constants/constants_test.go b/cmd/kubeadm/app/constants/constants_test.go index bc33346a8d2..7ac9e271fba 100644 --- a/cmd/kubeadm/app/constants/constants_test.go +++ b/cmd/kubeadm/app/constants/constants_test.go @@ -124,11 +124,15 @@ func TestGetStaticPodFilepath(t *testing.T) { } } +func TestEtcdSupportedVersionLength(t *testing.T) { + const max = 3 + if len(SupportedEtcdVersion) > max { + t.Fatalf("SupportedEtcdVersion must not include more than %d versions", max) + } +} + func TestEtcdSupportedVersion(t *testing.T) { var supportedEtcdVersion = map[uint8]string{ - 13: "3.2.24", - 14: "3.3.10", - 15: "3.3.10", 16: "3.3.17-0", 17: "3.4.3-0", 18: "3.4.3-0", @@ -147,7 +151,7 @@ func TestEtcdSupportedVersion(t *testing.T) { }, { kubernetesVersion: "1.10.1", - expectedVersion: version.MustParseSemantic("3.2.24"), + expectedVersion: version.MustParseSemantic("3.3.17-0"), expectedWarning: true, expectedError: false, },