feat: DB password rotation drill with pool credential refresh + safety guardrails (Closes #718) - #801
Open
laurentketterle-hub wants to merge 2 commits into
Conversation
…y guardrails
- Add rotatePoolCredentials() to src/db/pool.ts:
- DB_ROTATION_ENABLED safety gate (no-op by default)
- Smoke-test query before swapping pool
- Graceful old-pool drain (5s timeout)
- Event listeners for rotation/failure notifications
- Metric counters: db.pool.credential_rotation / _failed
- Add drill script scripts/drill-db-password-rotation.sh:
- Production URL guard (refuses prod)
- Pre/post rotation connection verification
- Staging health endpoint check
- Add pool.rotation.test.ts with 8 test cases
- No-op when disabled, smoke-test, failure counter,
listeners, env fallback, config override, cleanup
Closes RevoraOrg#718
Contributor
Author
|
I claim this bounty. PR ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements database password rotation with runtime pool credential refresh, a rehearsal drill script, and comprehensive tests.
Changes
src/db/pool.ts— AddedrotatePoolCredentials():DB_ROTATION_ENABLED=true(safe-by-default, no-op otherwise)SELECT 1before swapping the active poolonCredentialsRotated) for rotation/failure notificationsdb.pool.credential_rotation(success) anddb.pool.credential_rotation_failedscripts/drill-db-password-rotation.sh— Rehearsal script:src/db/pool.rotation.test.ts— 8 test cases:clearRotationListenerscleanupSafety Guardrails
DB_ROTATION_ENABLEDmust be explicitly set for rotation to take effectCloses #718