Repository navigation
ROX-29509: Reload TLS certificates in central-db and scanner-v4-db - #20335
Conversation
|
Skipping CI for Draft Pull Request. |
🚀 Build Images ReadyImages are ready for commit 7cc8a15. To use with deploy scripts: export MAIN_IMAGE_TAG=4.11.x-1036-g7cc8a1553a |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #20335 +/- ##
=======================================
Coverage 49.64% 49.64%
=======================================
Files 2799 2799
Lines 212917 212917
=======================================
Hits 105692 105692
Misses 99486 99486
Partials 7739 7739
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6b18d32 to
ccdd1ca
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThis PR introduces automatic TLS certificate reloading for PostgreSQL databases by adding a cert-watcher sidecar that polls certificate files, detects changes via MD5 hashing, and triggers PostgreSQL reload without requiring manual SIGHUP signals. ChangesPostgreSQL Certificate Reload
Sequence Diagram(s)sequenceDiagram
participant CertWatcher as cert-watcher<br/>sidecar
participant FSys as TLS Certificate<br/>Files
participant PostgreSQL as PostgreSQL<br/>Database
loop Every ROX_CERT_POLL_INTERVAL
CertWatcher->>FSys: Read and hash<br/>server.crt + server.key
FSys-->>CertWatcher: Combined MD5 hash
CertWatcher->>CertWatcher: Compare with<br/>previous hash
end
alt Hash changed
CertWatcher->>PostgreSQL: pg_ctl reload -D $PGDATA
PostgreSQL-->>CertWatcher: Reload completed
CertWatcher->>CertWatcher: Update stored hash
else Hash unchanged
CertWatcher->>CertWatcher: Wait for next poll
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Comment |
porridge
left a comment
There was a problem hiding this comment.
How about adding a CI check that makes sure these two scripts are in sync? This will allow engineers to realize they need to be maintained in lockstep.
cea552b to
cdb4420
Compare
|
/test ocp-4-12-scanner-v4-install-tests |
cdb4420 to
789126b
Compare
|
CodeRabbit chat interactions are restricted to organization members for this repository. Ask an organization member to interact with CodeRabbit, or set |
789126b to
1f0a93d
Compare
Description
This PR introduces TLS certificate hot reloading for
central-dbandscanner-v4-db, by means of a sidecar container that notifies PostgreSQL viapg_ctlto reload its configuration, when it detects a change in configuration.The
cert-watcher.shscript is duplicated betweenimage/postgres/scripts/(central-db) andscanner/image/db/scripts/(scanner-v4-db) because these two images have separate build contexts and independent Dockerfiles with no existing mechanism for sharing scripts between them. This is consistent with howdocker-entrypoint.shandinit-entrypoint.share already maintained independently in both locations.Alternatives considered:
docker-entrypoint.shis a simple solution, but it's not really observable (compared to the sidecar where we can inspect the logs of thecert-watchercontainer)pg_ctlin the main imageUser-facing documentation
Testing and quality
Automated testing
How I validated my change
Generated new certificates (with the CA from
central-tls) and replacedcentral-db-tls.Checked:
cert-watchersidecar logs:central-dbpostgres logs:openssl s_clientthat central-db now presents the new certificatesAlso tried bogus certificates, in that case postgres refuses to load the new certs:
The same tests were performed for
scanner-v4-dbas well.