66 "fmt"
77 "io"
88 "os"
9+ "strings"
10+ "time"
911
1012 "github.com/cenkalti/backoff/v4"
1113 "github.com/docker/go-units"
@@ -32,6 +34,7 @@ func (s *EdgeRuntimeAPI) UpsertFunctions(ctx context.Context, functionConfig con
3234 for _ , f := range result {
3335 exists [f .Slug ] = struct {}{}
3436 }
37+ policy := backoff .WithContext (backoff .WithMaxRetries (backoff .NewExponentialBackOff (), maxRetries ), ctx )
3538 var toUpdate []api.BulkUpdateFunctionBody
3639OUTER:
3740 for slug , function := range functionConfig {
@@ -59,12 +62,16 @@ OUTER:
5962 }
6063 functionSize := units .HumanSize (float64 (body .Len ()))
6164 fmt .Fprintf (os .Stderr , "Deploying Function: %s (script size: %s)\n " , slug , functionSize )
62- policy := backoff .WithContext (backoff .WithMaxRetries (backoff .NewExponentialBackOff (), maxRetries ), ctx )
63- result , err := backoff .RetryWithData (upsert , policy )
65+ result , err := backoff .RetryNotifyWithData (upsert , policy , func (err error , d time.Duration ) {
66+ if strings .Contains (err .Error (), "Duplicated function slug" ) {
67+ exists [slug ] = struct {}{}
68+ }
69+ })
6470 if err != nil {
6571 return err
6672 }
6773 toUpdate = append (toUpdate , result )
74+ policy .Reset ()
6875 }
6976 if len (toUpdate ) > 1 {
7077 if resp , err := s .client .V1BulkUpdateFunctionsWithResponse (ctx , s .project , toUpdate ); err != nil {
0 commit comments