Skip to content

Commit

Permalink
Merge pull request #847 from mjura/eks-update-order-main
Browse files Browse the repository at this point in the history
Change order of applying changes to EKS
  • Loading branch information
mjura authored Sep 30, 2024
2 parents ba16f71 + 3f8c2f1 commit ff97e78
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 ff97e78

Please sign in to comment.