Skip to content

Commit

Permalink
[release-21.0] S3: optional endpoint resolver and correct retrier (#1…
Browse files Browse the repository at this point in the history
…7307)

Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui authored Dec 2, 2024
1 parent 44d515e commit cac7524
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions go/vt/mysqlctl/s3backupstorage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -505,13 +506,24 @@ func (bs *S3BackupStorage) client() (*s3.Client, error) {
return nil, err
}

bs._client = s3.NewFromConfig(cfg, func(o *s3.Options) {
o.UsePathStyle = forcePath
if retryCount >= 0 {
o.RetryMaxAttempts = retryCount
o.Retryer = &ClosedConnectionRetryer{}
}
}, s3.WithEndpointResolverV2(newEndpointResolver()))
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 != "" {
options = append(options, s3.WithEndpointResolverV2(newEndpointResolver()))
}

bs._client = s3.NewFromConfig(cfg, options...)

if len(bucket) == 0 {
return nil, fmt.Errorf("--s3_backup_storage_bucket required")
Expand Down

0 comments on commit cac7524

Please sign in to comment.