From 1588d1df5e9a2eee839bf4a42d4f7b7b515dc22b Mon Sep 17 00:00:00 2001 From: Dan Bryant Date: Mon, 30 Sep 2024 11:39:53 +0100 Subject: [PATCH] adjust to only support K8s 1.25 and newer --- controller/eks-cluster-config-handler.go | 11 +++-------- controller/eks-cluster-config-handler_test.go | 18 +++--------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/controller/eks-cluster-config-handler.go b/controller/eks-cluster-config-handler.go index 34efe519..cc73ef11 100644 --- a/controller/eks-cluster-config-handler.go +++ b/controller/eks-cluster-config-handler.go @@ -353,16 +353,11 @@ func validateUpdate(config *eksv1.EKSClusterConfig) error { if clusterVersion.EQ(*version) { continue } - if (clusterVersion.Minor < 25 && clusterVersion.Minor-version.Minor <= 2) || (clusterVersion.Minor >= 25 && clusterVersion.Minor-version.Minor <= 3) { + if clusterVersion.Minor-version.Minor <= 3 { continue } - if clusterVersion.Minor < 25 { - errs = append(errs, fmt.Sprintf("versions for cluster [%s] and node group [%s] are not compatible: for clusters running Kubernetes < 1.25 the "+ - "node group version may only be up to two minor versions older than the cluster version", aws.ToString(config.Spec.KubernetesVersion), aws.ToString(ng.Version))) - } else { - errs = append(errs, fmt.Sprintf("versions for cluster [%s] and node group [%s] are not compatible: for clusters running Kubernetes >= 1.25 the "+ - "node group version may only be up to three minor versions older than the cluster version", aws.ToString(config.Spec.KubernetesVersion), aws.ToString(ng.Version))) - } + errs = append(errs, fmt.Sprintf("versions for cluster [%s] and node group [%s] are not compatible: the "+ + "node group version may only be up to three minor versions older than the cluster version", aws.ToString(config.Spec.KubernetesVersion), aws.ToString(ng.Version))) } if len(errs) != 0 { return fmt.Errorf("%s", strings.Join(errs, ";")) diff --git a/controller/eks-cluster-config-handler_test.go b/controller/eks-cluster-config-handler_test.go index 04d38db9..63a2b182 100644 --- a/controller/eks-cluster-config-handler_test.go +++ b/controller/eks-cluster-config-handler_test.go @@ -209,19 +209,7 @@ var _ = Describe("updateCluster", func() { Expect(err).To(MatchError("node group name [ng1] is not unique within the cluster [test (id: test)] to avoid duplication")) }) - It("should not allow node group versions outside version skew for Kubernetes < 1.25", func() { - eksConfig.Status.Phase = "active" - eksConfig.Spec.KubernetesVersion = aws.String("1.24") - eksConfig.Spec.NodeGroups = append(eksConfig.Spec.NodeGroups, eksv1.NodeGroup{ - NodegroupName: aws.String("ng2"), - Version: aws.String("1.21"), - }) - _, err := handler.OnEksConfigChanged("", eksConfig) - Expect(err).To(MatchError("versions for cluster [1.24] and node group [1.21] are not compatible: for clusters running Kubernetes < 1.25 the " + - "node group version may only be up to two minor versions older than the cluster version")) - }) - - It("should not allow node group versions outside version skew for Kubernetes >= 1.25", func() { + It("should not allow node group versions outside version skew", func() { eksConfig.Status.Phase = "active" eksConfig.Spec.KubernetesVersion = aws.String("1.25") eksConfig.Spec.NodeGroups = append(eksConfig.Spec.NodeGroups, eksv1.NodeGroup{ @@ -229,7 +217,7 @@ var _ = Describe("updateCluster", func() { Version: aws.String("1.21"), }) _, err := handler.OnEksConfigChanged("", eksConfig) - Expect(err).To(MatchError("versions for cluster [1.25] and node group [1.21] are not compatible: for clusters running Kubernetes >= 1.25 the " + - "node group version may only be up to three minor versions older than the cluster version")) + Expect(err).To(MatchError("versions for cluster [1.25] and node group [1.21] are not compatible: " + + "the node group version may only be up to three minor versions older than the cluster version")) }) })