From cf9791d97b9d883778c3fbd9b9f5170f7bf71337 Mon Sep 17 00:00:00 2001 From: Igor Anic Date: Sat, 25 Dec 2021 15:27:55 +0100 Subject: [PATCH] don't wait 5 seconds on for each lambda update --- aws/lambda.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/aws/lambda.go b/aws/lambda.go index d8ba11f7..063519dc 100644 --- a/aws/lambda.go +++ b/aws/lambda.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/lambda" lambdaTypes "github.com/aws/aws-sdk-go-v2/service/lambda/types" + "github.com/mantil-io/mantil/cli/log" ) func (a *AWS) LambdaExists(name string) (bool, error) { @@ -179,9 +180,16 @@ func (a *AWS) WaitLambdaFunctionUpdated(function string) error { FunctionName: aws.String(function), } - retryInterval := 5 * time.Second + retryInterval := 100 * time.Millisecond retryAttempts := 60 for retryAttempts > 0 { + log.Printf("wait for lambda function attemptd: %d, interval: %d", retryAttempts, retryInterval) + + time.Sleep(retryInterval) + retryAttempts-- + if retryAttempts < 50 && retryInterval < time.Second { + retryInterval = retryInterval * 2 + } gfco, err := a.lambdaClient.GetFunctionConfiguration(context.Background(), gfci) if err != nil { return err @@ -192,8 +200,7 @@ func (a *AWS) WaitLambdaFunctionUpdated(function string) error { if gfco.LastUpdateStatus == lambdaTypes.LastUpdateStatusFailed { return errors.New(*gfco.LastUpdateStatusReason) } - time.Sleep(retryInterval) - retryAttempts-- + } return nil }