Skip to content

session: make session auth timeout configurable - #7143

Open
paulbsch wants to merge 1 commit into
moby:masterfrom
paulbsch:paul-schroeder/configurable-session-auth-timeout
Open

paulbsch wants to merge 1 commit into
moby:masterfrom
paulbsch:paul-schroeder/configurable-session-auth-timeout

Conversation

@paulbsch

Copy link
Copy Markdown

Motivation

The timeout for daemon-side session auth round-trips with the buildx client session (resolving credentials, fetching auth tokens, verifying token authority) is hardcoded to 60 seconds (session/auth/auth.go). In clusters where the buildx client, a load balancer, or the registry credential chain is slow, the daemon-side auth deadline can expire before the round-trip completes, surfacing as DeadlineExceeded errors on pushes even though the daemon and client are healthy.

Description

Turn the package-level const sessionAuthTimeout into an exported var, SessionAuthTimeout, and make it configurable from buildkitd.toml via [system].sessionAuthTimeout, applied at daemon start in the existing [system] block, following the same pattern as [system].platformsCacheMaxAge (and the archutil.CacheMaxAge const→var precedent).

The value accepts a duration string (e.g. "48h") or a bare integer treated as seconds, reusing the existing config.Duration type. If unset, the default of 60s is kept, so existing deployments see no behavior change. A configured value of zero or less disables the deadline entirely: the new withTimeout helper skips the context.WithTimeoutCause call for non-positive values, because a zero-duration context would expire immediately and fail every auth round-trip. The deadline being skipped is still parent-cancellable.

Exported function signatures in the package are unchanged.

Testing

  • go test -count=1 ./cmd/buildkitd/config/... ./session/... ./util/resolver/... — all pass (includes new TestLoadSessionAuthTimeout covering unset / 0 / 300 / "48h" forms)
  • go build ./..., go vet, gofmt — clean
  • docker buildx bake lint-default0 issues.
  • Behavioral verification against a real gRPC session server: a server responding in ~1.2s completes when the timeout is disabled; a 500ms timeout against a 30s server fails in ~501ms with DeadlineExceeded; negative and "-30s" values disable; parent cancellation still aborts when the deadline is skipped.

The timeout for daemon-side session auth round-trips with the buildx
client session (resolving credentials, fetching auth tokens, verifying
token authority) was hardcoded to 60 seconds. Turn the package-level
const into an exported var, SessionAuthTimeout, and make it
configurable from buildkitd.toml via [system].sessionAuthTimeout,
applied at daemon start in the existing [system] block, following the
same pattern as [system].platformsCacheMaxAge.

The value accepts a duration string (e.g. "48h") or a bare integer
treated as seconds, reusing the existing config.Duration type. If
unset, the default of 60s is kept, so existing deployments see no
behavior change. A configured value of zero or less disables the
deadline entirely: the withTimeout helper skips the
context.WithTimeoutCause call for non-positive values, because a
zero-duration context would expire immediately and fail every auth
round-trip.

Signed-off-by: Paul Schroeder <paul.schroeder@pingidentity.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant