Secrets rotation lab
Design retries, degradation, and recovery
When revoke v1 while indexer still cached v1 → 401 storm, the system must degrade on purpose without widening blast radius.
1Try it yourself
Decision drill
Secrets rotation lab
Revoke leaked keys, rotate on schedule, audit access.
1/3API key found in a public gist.
2Learn the idea
Read
Classify and bound retries
Map failure classes for secrets manager path openai/prod: retryable vs fatal vs needs-human. Retries need budgets, jitter, and idempotency rules aligned to dual-key window: readers accept v1+v2; revoke v1 only after emit proves zero v1 use for 30m. The chapter’s signature failure — revoke v1 while indexer still cached v1 → 401 storm — must take a deliberate branch, not a generic catch-all.
Read
Containment path
Implement the degrade/rollback/refuse behavior security engineer rotating openai/prod after contractor offboarding needs when SEC-REVOKE-EARLY-21 repeats. Prefer scoped controls (one flag, one weight, one tenant, one secret version) over fleet-wide restarts. Preserve evidence; do not delete logs to “clean the demo.”
Read
Implementation artifact
if auth_fail_rate > 0.02:
sm.unrevoke("openai/prod", "v1") # emergency only, ticketed
Read
Verify harm reduction
After containment, check secret_version_share and auth_fail_rate moves in the safe direction and watch for retry amplification. Write the stop condition that ends the incident response for this lab.
Read
Stage depth
Chaos note: inject only one fault class at a time and restore fixtures after. Watch for dual failures — dependency down and retry amplifier — which is how revoke v1 while indexer still cached v1 → 401 storm becomes an outage. Customer communication templates (even if only for the drill) beat silence. If you queue deferred work, define poison-message handling. Budget documents should state the maximum extra spend allowed during retries. Close the loop by linking the containment action to a dashboard panel for secret_version_share and auth_fail_rate.
Read
Field notes for `secrets-rotation-lab` / `failure-handling`
Draw a state diagram for degrade modes and put it in the repo as ASCII if needed. Cap concurrent retries across the process, not only per request. Ensure cancellation propagates to downstream HTTP clients. When failing closed, choose a user-visible message that does not leak internals. Practice the single command that flips the kill switch or weight to zero. After recovery, drain or inspect deferred work before declaring green. In this chapter the product is answer API + indexer sharing provider key via versioned secrets manager, the human stakeholder is security engineer rotating openai/prod after contractor offboarding, and the incident id you design against is SEC-REVOKE-EARLY-21. Re-state the oracle in your notes — rotate to v2 → deploy → traffic on v2 → revoke v1 with audit event ROT-2026-07-30 — and keep the invariant visible: dual-key window: readers accept v1+v2; revoke v1 only after emit proves zero v1 use for 30m. Track secret_version_share and auth_fail_rate as the scoreboard. Surface under change control: secrets manager path openai/prod. If you only have forty minutes, finish the fixture for revoke v1 while indexer still cached v1 → 401 storm before polishing UI. Promotion language stays ternary: promote, hold, or roll back based on evidence, not hope.
Go deeper
Before you start
Why this matters
Assume revoke v1 while indexer still cached v1 → 401 storm is happening right now. Write the first safe action, the signal that confirms containment, and the action you will not take (infinite retry, broad restart, deleting evidence). Tie the plan to invariant: dual-key window: readers accept v1+v2; revoke v1 only after emit proves zero v1 use for 30m.
Related lessons
Check your understanding
Page assessment
Answer from memory. Completion is saved from this evidence, not from opening the next page.
All responses are required.