Skip to content

Commit

Permalink
Merge pull request #299 from jaxesn/jgw/retry-test-stack
Browse files Browse the repository at this point in the history
adds retry to test stack deployment
  • Loading branch information
jaxesn authored Jan 17, 2025
2 parents 235eafa + 6eeee85 commit 553260d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aws/eks-hybrid

go 1.21
go 1.22

require (
github.com/aws/aws-sdk-go v1.55.5
Expand Down
21 changes: 16 additions & 5 deletions test/e2e/credentials/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@ type StackOutput struct {
}

func (s *Stack) Deploy(ctx context.Context, logger logr.Logger) (*StackOutput, error) {
if err := s.deployStack(ctx, logger); err != nil {
// There is a race when creating the iam roles anywhere profile in cfn
// where the profile gets created, but cfn tries to get the tags before
// the resource has been fully created, attempt 1 retry
var err error
for range 2 {
if err = s.deployStack(ctx, logger); err == nil {
break
}
}
if err != nil {
return nil, err
}

Expand Down Expand Up @@ -118,9 +127,10 @@ func (s *Stack) deployStack(ctx context.Context, logger logr.Logger) error {
if resp == nil || len(resp.Stacks) == 0 {
logger.Info("Creating hybrid nodes stack", "stackName", s.Name)
_, err = s.CFN.CreateStack(ctx, &cloudformation.CreateStackInput{
StackName: aws.String(s.Name),
TemplateBody: aws.String(buf.String()),
Parameters: params,
DisableRollback: aws.Bool(true),
StackName: aws.String(s.Name),
TemplateBody: aws.String(buf.String()),
Parameters: params,
Capabilities: []cfnTypes.Capability{
"CAPABILITY_NAMED_IAM",
},
Expand All @@ -142,7 +152,8 @@ func (s *Stack) deployStack(ctx context.Context, logger logr.Logger) error {
} else {
logger.Info("Updating hybrid nodes stack", "stackName", s.Name)
_, err = s.CFN.UpdateStack(ctx, &cloudformation.UpdateStackInput{
StackName: aws.String(s.Name),
DisableRollback: aws.Bool(true),
StackName: aws.String(s.Name),
Capabilities: []cfnTypes.Capability{
"CAPABILITY_NAMED_IAM",
},
Expand Down

0 comments on commit 553260d

Please sign in to comment.