Skip to content

Commit

Permalink
Merge branch 'main' into aws-sdk-go-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed Sep 22, 2023
2 parents 5e01f9e + cc75712 commit 151245e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,11 @@ func (app *App) updateFunctionCode(ctx context.Context, in *lambdav2.UpdateFunct
return nil, err
}

var res *lambdav2.UpdateFunctionCodeOutput
retrier := retryPolicy.Start(ctx)
for retrier.Continue() {
res, err := app.lambdav2.UpdateFunctionCode(ctx, in)
var err error
res, err = app.lambdav2.UpdateFunctionCode(ctx, in)
if err != nil {
var rce *lambdav2types.ResourceConflictException
if errors.As(err, &rce) {
Expand All @@ -220,10 +222,20 @@ func (app *App) updateFunctionCode(ctx context.Context, in *lambdav2.UpdateFunct
}
return nil, fmt.Errorf("failed to update function code: %w", err)
}
log.Println("[info] updated function code successfully")
return res, nil
log.Println("[info] update function code request was accepted")
break
}

if !retrier.Continue() {
return nil, fmt.Errorf("failed to update function code (max retries reached)")
}

if err := app.waitForLastUpdateStatusSuccessful(ctx, *in.FunctionName); err != nil {
return nil, err
}
return nil, fmt.Errorf("failed to update function code (max retries reached)")
log.Println("[info] updated function code successfully")

return res, nil
}

func (app *App) waitForLastUpdateStatusSuccessful(ctx context.Context, name string) error {
Expand Down

0 comments on commit 151245e

Please sign in to comment.