br: fix s3 timeout (#41649)

close pingcap/tidb#41650
This commit is contained in:
CharlesCheung
2023-02-23 14:07:06 +08:00
committed by GitHub
parent 41e44fbf5a
commit 7cac20ee19
2 changed files with 3 additions and 3 deletions

View File

@ -289,7 +289,7 @@ func createOssRAMCred() (*credentials.Credentials, error) {
}
// NewS3Storage initialize a new s3 storage for metadata.
func NewS3Storage(backend *backuppb.S3, opts *ExternalStorageOptions) (obj *S3Storage, errRet error) {
func NewS3Storage(ctx context.Context, backend *backuppb.S3, opts *ExternalStorageOptions) (obj *S3Storage, errRet error) {
qs := *backend
awsConfig := aws.NewConfig().
WithS3ForcePathStyle(qs.ForcePathStyle).
@ -371,7 +371,7 @@ func NewS3Storage(backend *backuppb.S3, opts *ExternalStorageOptions) (obj *S3St
req.Config.S3ForcePathStyle = ses.Config.S3ForcePathStyle
}
}
region, err := s3manager.GetBucketRegionWithClient(context.Background(), c, qs.Bucket, setCredOpt)
region, err := s3manager.GetBucketRegionWithClient(ctx, c, qs.Bucket, setCredOpt)
if err != nil {
return nil, errors.Annotatef(err, "failed to get region of bucket %s", qs.Bucket)
}

View File

@ -176,7 +176,7 @@ func New(ctx context.Context, backend *backuppb.StorageBackend, opts *ExternalSt
if backend.S3 == nil {
return nil, errors.Annotate(berrors.ErrStorageInvalidConfig, "s3 config not found")
}
return NewS3Storage(backend.S3, opts)
return NewS3Storage(ctx, backend.S3, opts)
case *backuppb.StorageBackend_Noop:
return newNoopStorage(), nil
case *backuppb.StorageBackend_Gcs: