From 95a018f3cebe8398a823fcdf98efe0f466b2b0dc Mon Sep 17 00:00:00 2001 From: Michal Jura Date: Thu, 26 Sep 2024 10:33:58 +0200 Subject: [PATCH] Change order of applying changes to EKS Issue: https://github.com/rancher/eks-operator/issues/752 --- controller/eks-cluster-config-handler.go | 52 ++++++++++++------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/controller/eks-cluster-config-handler.go b/controller/eks-cluster-config-handler.go index f6cb27be..f66a88e5 100644 --- a/controller/eks-cluster-config-handler.go +++ b/controller/eks-cluster-config-handler.go @@ -720,6 +720,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{ @@ -751,32 +777,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)