Renew AIWB OpenBao token instead of rotating it - #816
Conversation
AIWB reads OPENBAO_TOKEN once at import and builds its OpenBao client at startup, so the value is snapshotted when the pod starts. The scoped token was minted with -ttl=768h and re-minted (and the old one revoked) once it expired, which stranded the running aiwb-api pod on a dead credential: every API-key create returned 500 from a 403 on secrets/data/apikeys/*, until someone restarted the deployment. Observed on app-dev. Mint the token periodic and renew it on each run so the stored value stays constant and nothing has to notice a rotation. A non-periodic token cannot be renewed past the system max TTL, so renewal alone would not have helped. Re-mint remains the fallback when the token is absent or no longer renewable, which also migrates the existing non-periodic token on its next expiry. The policy gains auth/token/renew-self, matching read-policy which already grants it to the external-secrets identity.
|
@johnl-amd Can you guys give any testing evidence here? |
|
Testing evidence from app-dev, all against the live OpenBao. The current token, showing the problem is real: No Why renewal alone would not have been enough: System max equals the creation TTL, so a non-periodic token can never be renewed past its original 32 days. What the mint change produces. Minted both ways against the live policy:
Both test tokens revoked afterwards. Compressed lifecycle test. Same mechanism at tiny scale so it finishes in under three minutes. Token A is non-periodic with a 90s hard cap standing in for the system max, token B is periodic with a 60s period. Both renewed every 25s. The thing to look at is A's ttl coming back smaller every time, 59s then 39s then 14s. Renewal keeps succeeding but only ever hands back what is left before the cap, then the token dies. That is exactly what the deployed token will do on 2026-09-23. B resets to a full period every time and never approaches a cap. One correction to the PR body. The The pending rotation on 2026-09-23 still stands either way. |
Summary
-period=768hinstead of-ttl=768h) and renew it on every secret-manager run, so the stored token value stays constant instead of rotating.auth/token/renew-selfinapikeys-write-policy, matching whatread-policyalready grants the external-secrets identity.Why: creating an API key in AI Workbench returns 500. Observed on app-dev.
Root cause:
aiwb-apireadsOPENBAO_TOKENfrom the environment once at import (app/openbao/config.py) and builds its OpenBao client at startup, so the value is snapshotted when the pod starts. The scoped token was minted with a 32-day TTL; on expiry the secret-manager re-mints and revokes the old one. ESO updates the Secret, but the running pod keeps presenting the revoked token, so every write tosecrets/data/apikeys/*returns 403, surfacing as a 500 from the create endpoint. It stays broken until someone restarts the deployment. Nothing was misconfigured; this is missing lifecycle handling around a credential that was deliberately scoped rather than reusing the root token (EAI-7277).Why periodic rather than just renewing: a non-periodic token cannot be renewed past the system max TTL, so adding renewal alone would not have prevented the expiry. Verified against the running OpenBao: a periodic token reports
period 768h/explicit_max_ttl 0sand renewal resets its lease, while-ttl=768hproduces noperiodand stays capped from creation.Note on the CLI: there is no
bao token renew-selfsubcommand.bao token renewwith no argument callsauth/token/renew-self, which is what the policy grant covers.Risk: low. Confined to the secret-manager script. The policy addition mirrors an existing grant, and the mint change only affects tokens created from here on.
Impact
One rotation is still pending. The token currently deployed is non-periodic and expires 2026-09-23. Even with this merged it will fail renewal then, be re-minted as periodic, and strand
aiwb-apionce more. Either accept a restart around that date, or force the rotation at a controlled time and restart the pod.Non-goals
This does not stop a manual re-mint from stranding the pod, because the token is still read once at startup. The durable fix is for AIWB to authenticate rather than hold a token, the way external-secrets already does via userpass against
read-policy. Worth a separate ticket.Test plan
SKIP: secrets/aiwb-openbao-token (scoped token renewed)instead of(scoped token still valid).bao token lookupon the stored token reportsperiod 768h.aiwb-api.