Skip to content

Commit

Permalink
Merge pull request #860 from mjura/skew-v2.9
Browse files Browse the repository at this point in the history
[v2.9] update version skew policy
  • Loading branch information
mjura authored Sep 30, 2024
2 parents e6973af + ce743a8 commit 0f95eb7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions controller/eks-cluster-config-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func validateUpdate(config *eksv1.EKSClusterConfig) error {
var err error
clusterVersion, err = semver.New(fmt.Sprintf("%s.0", aws.ToString(config.Spec.KubernetesVersion)))
if err != nil {
return fmt.Errorf("improper version format for cluster [%s (id: %s)]: %s", config.Spec.DisplayName, config.Name, aws.ToString(config.Spec.KubernetesVersion))
return fmt.Errorf("invalid version format for cluster [%s (id: %s)]: %s", config.Spec.DisplayName, config.Name, aws.ToString(config.Spec.KubernetesVersion))
}
}

Expand All @@ -356,7 +356,7 @@ func validateUpdate(config *eksv1.EKSClusterConfig) error {
}
version, err := semver.New(fmt.Sprintf("%s.0", aws.ToString(ng.Version)))
if err != nil {
errs = append(errs, fmt.Sprintf("improper version format for nodegroup [%s]: %s", aws.ToString(ng.NodegroupName), aws.ToString(ng.Version)))
errs = append(errs, fmt.Sprintf("invalid version format for node group [%s]: %s", aws.ToString(ng.NodegroupName), aws.ToString(ng.Version)))
continue
}
if clusterVersion == nil {
Expand All @@ -365,11 +365,11 @@ func validateUpdate(config *eksv1.EKSClusterConfig) error {
if clusterVersion.EQ(*version) {
continue
}
if clusterVersion.Minor-version.Minor == 1 {
if clusterVersion.Minor-version.Minor <= 3 {
continue
}
errs = append(errs, fmt.Sprintf("versions for cluster [%s] and nodegroup [%s] not compatible: all nodegroup kubernetes versions"+
"must be equal to or one minor version lower than the cluster kubernetes 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
12 changes: 12 additions & 0 deletions controller/eks-cluster-config-handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,16 @@ var _ = Describe("updateCluster", func() {
_, err := handler.OnEksConfigChanged("", eksConfig)
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", 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: " +
"the node group version may only be up to three minor versions older than the cluster version"))
})
})

0 comments on commit 0f95eb7

Please sign in to comment.