-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
failed to access the gcs when use custom http client #47022
Labels
affects-6.5
affects-7.1
component/br
This issue is related to BR of TiDB.
severity/major
type/bug
The issue is confirmed as a bug.
Comments
Leavrth
added
type/bug
The issue is confirmed as a bug.
component/br
This issue is related to BR of TiDB.
affects-6.5
affects-7.1
labels
Sep 18, 2023
The gcs credential is saved in the |
ti-chi-bot
bot
added
may-affects-5.3
This bug maybe affects 5.3.x versions.
may-affects-5.4
This bug maybe affects 5.4.x versions.
may-affects-6.1
labels
Sep 18, 2023
13 tasks
Leavrth
removed
may-affects-5.3
This bug maybe affects 5.3.x versions.
may-affects-5.4
This bug maybe affects 5.4.x versions.
may-affects-6.1
labels
Sep 18, 2023
This was referenced Sep 18, 2023
There is another solution for this, we can wrap the transport provided in the users' diff --git a/br/pkg/storage/gcs.go b/br/pkg/storage/gcs.go
index f32d4344d9..468b03dda1 100644
--- a/br/pkg/storage/gcs.go
+++ b/br/pkg/storage/gcs.go
@@ -20,6 +20,8 @@ import (
"golang.org/x/oauth2/google"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
+
+ htransport "google.golang.org/api/transport/http"
)
const (
@@ -292,11 +294,16 @@ func NewGCSStorage(ctx context.Context, gcs *backuppb.GCS, opts *ExternalStorage
clientOps = append(clientOps, option.WithCredentialsJSON([]byte(gcs.GetCredentialsBlob())))
}
}
-
if gcs.Endpoint != "" {
clientOps = append(clientOps, option.WithEndpoint(gcs.Endpoint))
}
if opts.HTTPClient != nil {
+ var err error
+ opts.HTTPClient.Transport, err = htransport.NewTransport(ctx, opts.HTTPClient.Transport,
+ append(clientOps, option.WithScopes(storage.ScopeFullControl, "https://www.googleapis.com/auth/cloud-platform"))...)
+ if err != nil {
+ return nil, errors.Trace(err)
+ }
clientOps = append(clientOps, option.WithHTTPClient(opts.HTTPClient))
}
client, err := storage.NewClient(ctx, clientOps...)
diff --git a/br/pkg/storage/gcs_test.go b/br/pkg/storage/gcs_test.go
index c6d7e14b80..31c68c5ebc 100644 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
affects-6.5
affects-7.1
component/br
This issue is related to BR of TiDB.
severity/major
type/bug
The issue is confirmed as a bug.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
success
3. What did you see instead (Required)
failed
4. What is your TiDB version? (Required)
master, v6.5.4
The text was updated successfully, but these errors were encountered: