Skip to content

Commit

Permalink
adjust to only support K8s 1.25 and newer
Browse files Browse the repository at this point in the history
(cherry picked from commit 1588d1d)
  • Loading branch information
justdan96 authored and mjura committed Sep 30, 2024
1 parent bbe9c68 commit ce743a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
11 changes: 3 additions & 8 deletions controller/eks-cluster-config-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,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, ";"))
Expand Down
18 changes: 3 additions & 15 deletions controller/eks-cluster-config-handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,27 +209,15 @@ 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{
NodegroupName: aws.String("ng2"),
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"))
})
})

0 comments on commit ce743a8

Please sign in to comment.