From bde043bb23cd60785be3a111d2a866327fd56f2d Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 2 Dec 2024 08:16:56 -0600 Subject: [PATCH] Fix how the options slice is created Signed-off-by: Florent Poinsard --- go/vt/mysqlctl/s3backupstorage/s3.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/go/vt/mysqlctl/s3backupstorage/s3.go b/go/vt/mysqlctl/s3backupstorage/s3.go index e19f5d5445d..7301ba2658b 100644 --- a/go/vt/mysqlctl/s3backupstorage/s3.go +++ b/go/vt/mysqlctl/s3backupstorage/s3.go @@ -40,6 +40,7 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/retry" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/feature/s3/manager" "github.com/aws/aws-sdk-go-v2/service/s3" @@ -505,17 +506,24 @@ func (bs *S3BackupStorage) client() (*s3.Client, error) { return nil, err } - var endpointResolverV2 func(options *s3.Options) = nil + options := []func(options *s3.Options){ + func(o *s3.Options) { + o.UsePathStyle = forcePath + if retryCount >= 0 { + o.RetryMaxAttempts = retryCount + o.Retryer = &ClosedConnectionRetryer{ + awsRetryer: retry.NewStandard(func(options *retry.StandardOptions) { + options.MaxAttempts = retryCount + }), + } + } + }, + } if endpoint != "" { - endpointResolverV2 = s3.WithEndpointResolverV2(newEndpointResolver()) + options = append(options, s3.WithEndpointResolverV2(newEndpointResolver())) } - bs._client = s3.NewFromConfig(cfg, func(o *s3.Options) { - o.UsePathStyle = forcePath - if retryCount >= 0 { - o.RetryMaxAttempts = retryCount - o.Retryer = &ClosedConnectionRetryer{} - } - }, endpointResolverV2) + + bs._client = s3.NewFromConfig(cfg, options...) if len(bucket) == 0 { return nil, fmt.Errorf("--s3_backup_storage_bucket required")