Skip to content

fix(authbridge): robust credential provisioning with continuous polling - #375

Merged
pdettori merged 1 commit into
rossoctl:mainfrom
pdettori:fix/robust-credential-provisioning
May 6, 2026
Merged

pdettori merged 1 commit into
rossoctl:mainfrom
pdettori:fix/robust-credential-provisioning

Conversation

@pdettori

@pdettori pdettori commented May 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace fire-once 60s credential file poll with continuous polling + exponential backoff (never gives up)
  • Add configurable credential_wait_timeout (default 120s) for the initial fast-poll phase
  • Return HTTP 503 (not silent 401) when identity credentials are still pending
  • Add /healthz and /readyz endpoints on port 9091 for Kubernetes readiness probes

Problem

The kagenti-client-registration sidecar occasionally takes >60s to register with Keycloak and write credential files. When this happens, AuthBridge's fire-once poll expires silently, leaving client_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

  1. Continuous polling: After the initial timeout (120s), keep trying with exponential backoff (5s, 10s, 20s... capped at 60s). Credentials are picked up whenever they appear.
  2. 503 pending state: Instead of a confusing 401 "audience is required" error, return 503 "identity not yet configured (credentials pending)" — a clear signal to retry.
  3. Readiness probe: The new /readyz endpoint returns 200 only after credentials load, preventing Kubernetes from routing traffic to the pod prematurely.

Test plan

Fixes: rossoctl/rossoctl#1480

Assisted-By: Claude Code

…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]>
@huang195

huang195 commented May 6, 2026

Copy link
Copy Markdown
Member

@pdettori I wonder if this PR will break what this PR (rossoctl/rossoctl#1447) do

@pdettori

pdettori commented May 6, 2026

Copy link
Copy Markdown
Member Author

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 (/readyz on port 9091) prevents traffic from reaching the pod until credentials are loaded, so clients should rarely see the 503. It's a safety net for the race window.

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.

@huang195 huang195 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants