Repository navigation
fix(authbridge): robust credential provisioning with continuous polling - #375
Conversation
…polling Replace the fire-once 60s poll for credential files with a continuous polling mechanism that never gives up. This fixes transient 401 errors in CI when the client-registration sidecar takes longer than 60s to write /shared/client-id.txt and /shared/client-secret.txt. Changes: - ResolveCredentialFiles now returns a ready channel and polls with exponential backoff (5s→60s) after the initial timeout expires - Add configurable credential_wait_timeout (default 120s) - Return 503 (not silent 401) when identity is not yet loaded - Add /healthz and /readyz HTTP endpoints on port 9091 for Kubernetes readiness probes Fixes: rossoctl/rossoctl#1480 Signed-off-by: Paolo Dettori <[email protected]> Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
|
@pdettori I wonder if this PR will break what this PR (rossoctl/rossoctl#1447) do |
|
Thanks for flagging! I checked PR #1447 and these two changes are actually complementary, not conflicting:
The 503 is intentional precisely because of #1447's logic: if we returned 401 during startup, the frontend would trigger a token refresh — which wouldn't help because the problem isn't the token, it's the server not being ready. 503 signals "retry later" without triggering a useless refresh loop. In practice, the Kubernetes readiness probe ( TL;DR: 401 = "your token is wrong, refresh it" (PR #1447's domain). 503 = "I'm not ready yet, try again shortly" (this PR's domain). They work together. |
Summary
credential_wait_timeout(default 120s) for the initial fast-poll phase/healthzand/readyzendpoints on port 9091 for Kubernetes readiness probesProblem
The
kagenti-client-registrationsidecar occasionally takes >60s to register with Keycloak and write credential files. When this happens, AuthBridge's fire-once poll expires silently, leavingclient_id="". All subsequent inbound JWT validation fails with 401 because audience defaults to the empty client_id.This was observed as a transient E2E failure in rossoctl/rossoctl#1480 (HyperShift CI).
Solution
/readyzendpoint returns 200 only after credentials load, preventing Kubernetes from routing traffic to the pod prematurely.Test plan
go test ./...)go buildsucceeds for authlib and cmd/authbridgeFixes: rossoctl/rossoctl#1480
Assisted-By: Claude Code