feat(health): M5-03 — /ready readiness probe, compose healthcheck gate#220
Merged
Conversation
… gate
- Add GET /ready that checks DB connectivity (SELECT 1) and runtime config
volume writable; returns 200 {"status":"ready",...} or 503 with per-check
breakdown so operators can tell which dependency is down
- Keep GET /health as a pure liveness probe (process-alive, no deps)
- Suppress GET /ready access-log noise in _HealthcheckAccessFilter
- Switch Docker Compose backend healthcheck from /health to /ready so the
entire dependent stack (frontend, haproxy, coraza, log-shipper) only starts
once the backend can actually serve real traffic
- Fix dead GUARD_PROXY_RUNTIME_DIR env var in compose → RUNTIME_GENERATED_CONFIG_ROOT
(value unchanged; previous name was never read by the Python settings layer)
- 12 tests (7 integration + 2 unit new, 3 existing unit retained)
Closes #128
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a real readiness probe to the FastAPI backend and wires Docker Compose health checks to gate dependent services on actual backend readiness (DB + runtime config volume), while keeping /health as a lightweight liveness endpoint.
Changes:
- Added
GET /readyreadiness probe (DBSELECT 1+ runtime generated config directory is writable) and updated access-log filtering to suppress probe noise. - Updated Compose backend healthcheck to call
/readyand fixed the runtime config env var name to match the backend settings field. - Added integration/unit tests for the probes and logging filter; updated README docs to document both endpoints.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/backend/app/main.py |
Implements /ready readiness probe and suppresses access logs for /ready polling. |
deploy/docker/docker-compose.yml |
Switches healthcheck endpoint to /ready and renames env var to RUNTIME_GENERATED_CONFIG_ROOT. |
src/backend/tests/integration/test_health_router.py |
Adds integration coverage for /health and /ready success/failure scenarios. |
src/backend/tests/unit/test_access_logging.py |
Extends unit coverage for access-log filter to include /ready. |
README.architecture.md |
Documents liveness vs readiness probes, response shape, and Compose gating behaviour. |
README.md |
Updates quickstart access table to list both probes. |
- Replace str(exc) in DB error detail with generic "database unavailable" message; log full exception at ERROR level instead to avoid leaking internal hostnames/credentials through the unauthenticated probe - Add os.X_OK to the runtime config dir access check (W_OK alone doesn't guarantee files can be created inside a directory) - Tighten test assertion to verify the generic detail string Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
3 tasks
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
GET /ready— a real readiness probe that checks DB connectivity (SELECT 1) and whether the runtime config volume is a writable directory. Returns200with per-check status when healthy,503with a detailed breakdown when any dependency is unavailable.GET /healthas a pure liveness probe (static 200, no dependencies checked).healthcheckfrom/health→/readyso the five dependent services (frontend,haproxy,coraza,log-shipper) only start once the backend can actually serve traffic.GUARD_PROXY_RUNTIME_DIRin compose was never read by the Python settings layer (field isRUNTIME_GENERATED_CONFIG_ROOT). Renamed to match; value is unchanged.What changed and why
src/backend/app/main.pyreadiness_checkendpoint; extends_HealthcheckAccessFilterto also suppressGET /readypoll noise; updated importsdeploy/docker/docker-compose.yml/health→/ready; env var rename fixtests/integration/test_health_router.pytests/unit/test_access_logging.pyREADME.architecture.mdREADME.mdResponse shape
Test plan
uv run python -m pytest tests/unit/test_access_logging.py tests/integration/test_health_router.py -v— 12/12 passedmake run→ confirm backend reacheshealthystate and all dependents startcurl -i localhost:8080/health(200),curl -i localhost:8080/ready(200)Closes #128