Skip to content

Commit

Permalink
Merge pull request #846 from mjura/eks-update-order
Browse files Browse the repository at this point in the history
[v2.9] Change order of applying changes to EKS
  • Loading branch information
mjura authored Sep 30, 2024
2 parents 1994fc0 + 95a018f commit 598e1a2
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions controller/eks-cluster-config-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,32 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
}
}

updated, err := awsservices.UpdateClusterAccess(ctx, &awsservices.UpdateClusterAccessOpts{
EKSService: awsSVCs.eks,
Config: config,
UpstreamClusterSpec: upstreamSpec,
})
if err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error updating cluster access config: %w", err)
}
if updated {
return h.enqueueUpdate(config)
}

if config.Spec.PublicAccessSources != nil {
updated, err := awsservices.UpdateClusterPublicAccessSources(ctx, &awsservices.UpdateClusterPublicAccessSourcesOpts{
EKSService: awsSVCs.eks,
Config: config,
UpstreamClusterSpec: upstreamSpec,
})
if err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error updating cluster public access sources: %w", err)
}
if updated {
return h.enqueueUpdate(config)
}
}

// check tags for update
if config.Spec.Tags != nil {
updated, err := awsservices.UpdateResourceTags(ctx, &awsservices.UpdateResourceTagsOpts{
Expand Down Expand Up @@ -763,32 +789,6 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
}
}

updated, err := awsservices.UpdateClusterAccess(ctx, &awsservices.UpdateClusterAccessOpts{
EKSService: awsSVCs.eks,
Config: config,
UpstreamClusterSpec: upstreamSpec,
})
if err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error updating cluster access config: %w", err)
}
if updated {
return h.enqueueUpdate(config)
}

if config.Spec.PublicAccessSources != nil {
updated, err := awsservices.UpdateClusterPublicAccessSources(ctx, &awsservices.UpdateClusterPublicAccessSourcesOpts{
EKSService: awsSVCs.eks,
Config: config,
UpstreamClusterSpec: upstreamSpec,
})
if err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error updating cluster public access sources: %w", err)
}
if updated {
return h.enqueueUpdate(config)
}
}

if config.Spec.NodeGroups == nil {
if config.Status.Phase != eksConfigActivePhase {
logrus.Infof("Cluster [%s (id: %s)] finished updating", config.Spec.DisplayName, config.Name)
Expand Down

0 comments on commit 598e1a2

Please sign in to comment.