Skip to content

Commit

Permalink
Skip error message when resource is in use
Browse files Browse the repository at this point in the history
  • Loading branch information
mjura committed Jun 12, 2024
1 parent 238a5d3 commit 26f2192
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ MOCKGEN_VER := v1.6.0
MOCKGEN_BIN := mockgen
MOCKGEN := $(BIN_DIR)/$(MOCKGEN_BIN)-$(MOCKGEN_VER)

GINKGO_VER := v2.17.2
GINKGO_VER := v2.19.0
GINKGO_BIN := ginkgo
GINKGO := $(BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER)

Expand Down
22 changes: 10 additions & 12 deletions controller/eks-cluster-config-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,8 @@ func (h *Handler) create(ctx context.Context, config *eksv1.EKSClusterConfig, aw
EKSService: awsSVCs.eks,
Config: config,
RoleARN: roleARN,
}); err != nil {
if !isClusterConflict(err) {
return config, fmt.Errorf("error creating cluster: %w", err)
}
}); err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error creating cluster: %w", err)
}

// If a user edits a cluster at the exact right (or wrong) time, then the
Expand Down Expand Up @@ -702,7 +700,7 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
Config: config,
UpstreamClusterSpec: upstreamSpec,
})
if err != nil {
if err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error updating cluster version: %w", err)
}
if updated {
Expand All @@ -718,7 +716,7 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
UpstreamTags: upstreamSpec.Tags,
ResourceARN: clusterARN,
})
if err != nil {
if err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error updating cluster tags: %w", err)
}
if updated {
Expand All @@ -733,7 +731,7 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
Config: config,
UpstreamClusterSpec: upstreamSpec,
})
if err != nil {
if err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error updating logging types: %w", err)
}
if updated {
Expand All @@ -746,7 +744,7 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
Config: config,
UpstreamClusterSpec: upstreamSpec,
})
if err != nil {
if err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error updating cluster access config: %w", err)
}
if updated {
Expand All @@ -759,7 +757,7 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
Config: config,
UpstreamClusterSpec: upstreamSpec,
})
if err != nil {
if err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error updating cluster public access sources: %w", err)
}
if updated {
Expand Down Expand Up @@ -801,7 +799,7 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
if err := awsservices.CreateLaunchTemplate(ctx, &awsservices.CreateLaunchTemplateOptions{
EC2Service: awsSVCs.ec2,
Config: config,
}); err != nil {
}); err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error getting or creating launch template: %w", err)
}
// in this case update is set right away because creating the
Expand All @@ -823,7 +821,7 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
NodeGroup: ng,
})

if err != nil {
if err != nil && !isResourceInUse(err) {
return config, fmt.Errorf("error creating nodegroup: %w", err)
}

Expand Down Expand Up @@ -940,7 +938,7 @@ func (h *Handler) updateUpstreamClusterState(ctx context.Context, upstreamSpec *
NodeGroup: &ng,
NGVersionInput: ngVersionInput,
LTVersions: templateVersionsToAdd,
}); err != nil {
}); err != nil && !isResourceInUse(err) {
return config, err
}
continue
Expand Down
2 changes: 1 addition & 1 deletion controller/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
)

func isClusterConflict(err error) bool {
func isResourceInUse(err error) bool {
var riu *ekstypes.ResourceInUseException
return errors.As(err, &riu)
}
Expand Down

0 comments on commit 26f2192

Please sign in to comment.