Skip to content

Commit

Permalink
Merge pull request #674 from mjura/main-version
Browse files Browse the repository at this point in the history
Prevent from downgrading Kubernetes versions
  • Loading branch information
mjura authored Jul 15, 2024
2 parents 857cb17 + 88abdfc commit 0cadba7
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions controller/eks-cluster-config-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,18 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
return config, fmt.Errorf("aws services not initialized")
}

configVersion, err := semver.ParseTolerant(aws.ToString(config.Spec.KubernetesVersion))
if err != nil {
return config, fmt.Errorf("couldn't parse config version: %w", err)
}
upstreamVersion, err := semver.ParseTolerant(aws.ToString(upstreamSpec.KubernetesVersion))
if err != nil {
return config, fmt.Errorf("couldn't parse upstream version: %w", err)
}

// check kubernetes version for update
if config.Spec.KubernetesVersion != nil {
if config.Spec.KubernetesVersion != nil &&
configVersion.GT(upstreamVersion) {
updated, err := awsservices.UpdateClusterVersion(ctx, &awsservices.UpdateClusterVersionOpts{
EKSService: awsSVCs.eks,
Config: config,
Expand Down Expand Up @@ -766,10 +776,14 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
}

if config.Spec.NodeGroups == nil {
logrus.Infof("cluster [%s] finished updating", config.Name)
config = config.DeepCopy()
config.Status.Phase = eksConfigActivePhase
return h.eksCC.UpdateStatus(config)
if config.Status.Phase != eksConfigActivePhase {
logrus.Infof("cluster [%s] finished updating", config.Name)
config = config.DeepCopy()
config.Status.Phase = eksConfigActivePhase
return h.eksCC.UpdateStatus(config)
}

return config, nil
}

// check nodegroups for updates
Expand Down

0 comments on commit 0cadba7

Please sign in to comment.