Repository navigation
feat(auth): add experimental token-provider fetch timeouts - #5230
singh4jitendra wants to merge 2 commits into
Conversation
Add a disabled-by-default experimental per-fetch timeout for custom HTTP and Unix token providers. Honor explicit source lifetime cancellation while detaching transient initialization contexts at cached adapters. Wire configuration, protobuf, validation, CLI, legacy authentication and telemetry consistently, with regression coverage and documentation.
There was a problem hiding this comment.
Code Review
This pull request introduces an experimental configuration parameter, experimental-token-url-timeout, which allows users to specify a timeout duration for custom token-URL requests. The changes span configuration structures, CLI flags, validation logic, protobuf definitions, and the underlying authentication client setup where the timeout is applied to the HTTP client fetching the tokens. Comprehensive unit tests have been added to verify the validation, CLI parsing, and timeout behaviors under various scenarios. No review comments were provided, so there is no additional feedback to address.
|
Hi @kislaykishore, could you have a look when you get a chance? This adds an opt-in timeout for token-provider requests, keeping the existing behavior unchanged by default. Local validation passed, but the GitHub workflows still need approval. Thanks! |
Merge current master without rewriting PR history. Preserve the PR behavior while adopting the upstream v4 module path, Go 1.27.4 and dependency security updates. Validated with relevant race tests and make build.
|
Merged the latest master in eb136e0 and resolved the generated-protobuf conflict. The timeout field is retained, and the code and new test now use the v4 module path. Rechecked with Go 1.27.4:
The PR behavior and history are preserved. Ready for the updated CI run and review. |
|
Hi @kislaykishore, just following up on this one. Could you take a look when you have a moment? Happy to make any changes you suggest. Thanks! |
|
Hi @kislaykishore, could you finish the review when you have a moment and merge if everything looks good? Thanks! |
|
Do we have a pressing use-case for this? |
|
Fair question, @kislaykishore. This came from code review rather than a reported production incident. The scenario I wanted to cover is a custom token provider accepting a request but never replying, leaving GCSFuse waiting for a token during mount or refresh. The timeout is opt-in, so existing setups behave the same. I see it as defensive hardening rather than an urgent fix. Happy to defer if you'd prefer a concrete user report first. |
|
Yep, I don't see the priority here. So, let's defer this. |
Description
gcs-auth.experimental-token-url-timeout/--experimental-token-url-timeout. Zero preserves existing unlimited-provider behavior, negative values are rejected, and positive values bound each custom token-provider fetch, including response body reading.Each source owns its HTTP client and any Unix-socket transport. No shared default client or transport is mutated. This is a compatibility-conscious hardening improvement, not a confirmed security vulnerability or a mount-shutdown cancellation implementation.
Link to the issue in case of a bug fix.
Fixes #5228
Testing details
Checks ran with Go 1.27.2 in Ubuntu 24.04 under WSL.
make build- passed, including generation, imports/formatting, dependency hygiene, vet, golangci-lint (0 issues), and compilation.go test -p 1 -count=1 -timeout=2m ./internal/auth ./internal/storage/storageutil ./cfg ./cmd ./internal/monitor -run "^(TestAuthSuite|Test_NewTokenSourceFromURL.*|TestProxyTokenSource.*|Test_GetClientAuthOptionsAndTokenSource.*|TestCustomTokenSourceTimeout|TestGetGcpOtelHttpClient_TokenURLTimeout|TestValidateConfig_ExperimentalTokenURLTimeout|TestToProto.*|TestSerializeConfigToProtoBase64.*|TestArgsParsing_GCSAuthFlags.*|TestValidateConfigFile_GCSAuthConfigSuccessful)$"- passed in all five packages.go test -race -p 1 -count=1 -timeout=2m ./internal/auth ./internal/storage/storageutil ./cfg ./cmd ./internal/monitor -run "^(TestAuthSuite|Test_NewTokenSourceFromURL.*|TestProxyTokenSource.*|Test_GetClientAuthOptionsAndTokenSource.*|TestCustomTokenSourceTimeout|TestGetGcpOtelHttpClient_TokenURLTimeout|TestValidateConfig_ExperimentalTokenURLTimeout|TestToProto.*|TestSerializeConfigToProtoBase64.*|TestArgsParsing_GCSAuthFlags.*|TestValidateConfigFile_GCSAuthConfigSuccessful)$"- passed in all five packages, with no race reports.Any backward incompatible change? If so, please explain.
The new experimental timeout defaults to zero, preserving existing provider latency behavior unless explicitly enabled. Direct constructor callers must use a context with token-source lifetime; cached production adapters deliberately do not capture short-lived lookup cancellation. No ADC/key-file or dependency changes are introduced.