Skip to content

config: synchronize OAuth2 transport replacement and cleanup - #1040

Open
ViktorBystrov72 wants to merge 1 commit into
prometheus:mainfrom
ViktorBystrov72:fix/oauth2-transport-snapshot
Open

ViktorBystrov72 wants to merge 1 commit into
prometheus:mainfrom
ViktorBystrov72:fix/oauth2-transport-snapshot

Conversation

@ViktorBystrov72

Copy link
Copy Markdown

Concurrent requests can race when an OAuth2 client secret is refreshed: RoundTrip copies the lastRT pointer under its lock, then oauth2.Transport.RoundTrip reads Source after the lock is released while another request overwrites it. CloseIdleConnections also reads the token HTTP client without the lock used to replace it.

Publish a new OAuth2 transport when replacing its source so in-flight requests keep an immutable transport. Snapshot the token client and base transport under the read lock before closing idle connections.

The regression uses concurrent HTTP requests, a rotating secret manager, and concurrent idle-connection cleanup. go test -race reports both races on the parent implementation. It passes five consecutive runs after the fix.

Validation: make test GOOPTS=-race passed with Go 1.27.3 and golangci-lint 2.14.0, including root tests, lint, license, and module-tidy checks. git diff --check passed.

@roidelapluie @gotjosh

@ViktorBystrov72
ViktorBystrov72 force-pushed the fix/oauth2-transport-snapshot branch 2 times, most recently from 4488a8f to c887d90 Compare November 12, 2026 04:53
Signed-off-by: Виктор Быстров <anatema@bk.ru>
@ViktorBystrov72
ViktorBystrov72 force-pushed the fix/oauth2-transport-snapshot branch from c887d90 to 5269da4 Compare November 13, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant