Skip to content

Any GCS Storage operation authenticating using external account (workload identity federation) will fail with "context canceled" #60155

@kennytm

Description

@kennytm

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. Create a credentials JSON file with the following content:
{
	"type":"external_account",
	"audience":"//iam.googleapis.com/projects/1234567890123/locations/global/workloadIdentityPools/my-pool/providers/my-provider",
	"subject_token_type":"urn:ietf:params:oauth:token-type:access_token",
	"credential_source":{"url":"http://127.0.0.1:12345/"}
}
  1. Starts an HTTP server at 127.0.0.1:12345
python3 -m http 12345
  1. Start a tiup playground and run BR backup using that credentials file.
tiup playground nightly --tiflash 0 --without-monitor
bin/br backup db --db test -s 'gcs://dummy/prefix' --gcs.credentials-file ./1.json --log-file -

2. What did you expect to see? (Required)

The backup failed because the credentials is invalid:

Error: error occurred when checking backupmeta file: 
  Get "https://storage.googleapis.com/storage/v1/b/dummy/o/prefix%2Fbackupmeta?alt=json&prettyPrint=false&projection=full": 
    oauth2/google: status code 400: 
      {"error":"invalid_target","error_description":"The target service indicated by the \"audience\" parameters is invalid. This might either be because the pool or provider is disabled or deleted or because it doesn't exist."}

3. What did you see instead (Required)

The request got outright canceled

Error: error occurred when checking backupmeta file: 
  Get "https://storage.googleapis.com/storage/v1/b/dummy/o/prefix%2Fbackupmeta?alt=json&prettyPrint=false&projection=full": 
    oauth2/google/externalaccount: invalid response when retrieving subject token: 
      Get "http://127.0.0.1:12345/": 
        context canceled

The stack trace is useless.

[2025/03/19 01:56:48.658 +08:00] [ERROR] [backup.go:58] ["failed to backup"] [error="error occurred when checking backupmeta file: Get \"https://storage.googleapis.com/storage/v1/b/dummy/o/prefix%2Fbackupmeta?alt=json&prettyPrint=false&projection=full\": oauth2/google/externalaccount: invalid response when retrieving subject token: Get \"http://127.0.0.1:12345/\": context canceled"] [errorVerbose="Get \"https://storage.googleapis.com/storage/v1/b/dummy/o/prefix%2Fbackupmeta?alt=json&prettyPrint=false&projection=full\": oauth2/google/externalaccount: invalid response when retrieving subject token: Get \"http://127.0.0.1:12345/\": context canceled
github.com/pingcap/errors.AddStack
	/Users/pingcap/go/pkg/mod/github.com/pingcap/[email protected]/errors.go:178
github.com/pingcap/errors.Trace
	/Users/pingcap/go/pkg/mod/github.com/pingcap/[email protected]/juju_adaptor.go:15
github.com/pingcap/tidb/br/pkg/storage.(*GCSStorage).FileExists
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-swnhn-build-binaries/source/tidb/br/pkg/storage/gcs.go:199
github.com/pingcap/tidb/br/pkg/backup.(*Client).SetStorageAndCheckNotInUse
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-swnhn-build-binaries/source/tidb/br/pkg/backup/client.go:502
github.com/pingcap/tidb/br/pkg/task.RunBackup
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-swnhn-build-binaries/source/tidb/br/pkg/task/backup.go:451
main.runBackupCommand
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-swnhn-build-binaries/source/tidb/br/cmd/br/backup.go:57
main.newDBBackupCommand.func1
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-swnhn-build-binaries/source/tidb/br/cmd/br/backup.go:164
github.com/spf13/cobra.(*Command).execute
	/Users/pingcap/go/pkg/mod/github.com/spf13/[email protected]/command.go:985
github.com/spf13/cobra.(*Command).ExecuteC
	/Users/pingcap/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117
github.com/spf13/cobra.(*Command).Execute
	/Users/pingcap/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
main.main
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-swnhn-build-binaries/source/tidb/br/cmd/br/main.go:36
runtime.main
	/usr/local/go1.23/src/runtime/proc.go:272
runtime.goexit
	/usr/local/go1.23/src/runtime/asm_arm64.s:1223
error occurred when checking backupmeta file"] [stack="main.runBackupCommand
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-swnhn-build-binaries/source/tidb/br/cmd/br/backup.go:58
main.newDBBackupCommand.func1
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-swnhn-build-binaries/source/tidb/br/cmd/br/backup.go:164
github.com/spf13/cobra.(*Command).execute
	/Users/pingcap/go/pkg/mod/github.com/spf13/[email protected]/command.go:985
github.com/spf13/cobra.(*Command).ExecuteC
	/Users/pingcap/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117
github.com/spf13/cobra.(*Command).Execute
	/Users/pingcap/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
main.main
	/Users/pingcap/workspace/bp-tidb-release-darwin-arm64-swnhn-build-binaries/source/tidb/br/cmd/br/main.go:36
runtime.main
	/usr/local/go1.23/src/runtime/proc.go:272"]

4. What is your TiDB version? (Required)

master, also v8.5.1

Metadata

Metadata

Assignees

Labels

affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.affects-9.0This bug affects the 9.0.x versions.component/lightningThis issue is related to Lightning of TiDB.found/gsfound by gsseverity/majortype/bugThe issue is confirmed as a bug.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions