Skip to content

Commit 407e708

Browse files
authored
br: not use the custom http client for gcs (pingcap#47026) (pingcap#47058)
close pingcap#47022
1 parent d7f8134 commit 407e708

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

br/pkg/storage/gcs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ func NewGCSStorage(ctx context.Context, gcs *backuppb.GCS, opts *ExternalStorage
296296
if gcs.Endpoint != "" {
297297
clientOps = append(clientOps, option.WithEndpoint(gcs.Endpoint))
298298
}
299+
// the HTTPClient should has credential, currently the HTTPClient only has the http.Transport.
300+
// So we remove the HTTPClient in the storage.New().
301+
// Issue: https: //github.com/pingcap/tidb/issues/47022
299302
if opts.HTTPClient != nil {
300303
clientOps = append(clientOps, option.WithHTTPClient(opts.HTTPClient))
301304
}

br/pkg/storage/storage.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ type ExternalStorageOptions struct {
132132
NoCredentials bool
133133

134134
// HTTPClient to use. The created storage may ignore this field if it is not
135-
// directly using HTTP (e.g. the local storage).
135+
// directly using HTTP (e.g. the local storage) or use self-design HTTP client
136+
// with credential (e.g. the gcs).
137+
// NOTICE: the HTTPClient is only used by s3 storage and azure blob storage.
136138
HTTPClient *http.Client
137139

138140
// CheckPermissions check the given permission in New() function.
@@ -185,6 +187,9 @@ func New(ctx context.Context, backend *backuppb.StorageBackend, opts *ExternalSt
185187
if backend.Gcs == nil {
186188
return nil, errors.Annotate(berrors.ErrStorageInvalidConfig, "GCS config not found")
187189
}
190+
// the HTTPClient should has credential, currently the HTTPClient only has the http.Transport.
191+
// Issue: https: //github.com/pingcap/tidb/issues/47022
192+
opts.HTTPClient = nil
188193
return NewGCSStorage(ctx, backend.Gcs, opts)
189194
case *backuppb.StorageBackend_AzureBlobStorage:
190195
return newAzureBlobStorage(ctx, backend.AzureBlobStorage, opts)

0 commit comments

Comments
 (0)