chore: switch health check to lightweight /health endpoint (#119) #125
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-database#125
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/119-chore-switch-health-check-to-lightweight-health-en"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #119
Summary
GET /healthendpoint toapp/main.pythat returns{"status": "ok"}without making any database queriesHEALTHCHECKto use/healthinstead of/api/v3/currentThe
/api/v3/currentendpoint makes DB queries on every health check, risking false-positive container restarts when the DB is temporarily slow. The new/healthendpoint returns 200 immediately with no queries.Files Changed
app/main.py— added/healthrouteDockerfile— updatedHEALTHCHECK CMDURLAI Code Review
Files Reviewed
app/main.py(modified)Dockerfile(modified)Findings
Correctness
No issues found. The
/healthendpoint correctly returns{"status": "ok"}with no SQL queries executed.include_in_schema=Falseappropriately hides it from OpenAPI docs. The Dockerfile HEALTHCHECK URL update is aligned with the new route path and port 80 is consistent with the uvicorn startup command.One nuance worth noting (non-blocking): the
db_connection_middlewareruns for all requests including/health, sodb.connect(reuse_if_open=True)is still called on every health check — it just doesn't execute any SQL. For aPooledPostgresqlDatabasethis is a pool-level operation (fast, no round-trip to PostgreSQL) rather than a query, so it satisfies the stated goal of avoiding slow-DB false positives. Fully bypassing the middleware would require checkingrequest.url.pathinside it, which is overkill for this use case.Security
{"status": "ok"}exposes no sensitive data.Style & Conventions
No issues. Follows FastAPI patterns used elsewhere in the project.
Suggestions
/diagnosticsendpoint (referenced in CLAUDE.md) or a future/readyendpoint could be used if DB connectivity health is ever needed separately from process health. The current implementation is appropriate for its stated purpose.Verdict: COMMENT
Clean, correct implementation. Achieves the stated goal —
/healthreplaces/api/v3/currentin the HEALTHCHECK, eliminating SQL queries from the health check path. Approved.Automated review by Claude PR Reviewer
Superceded by #127
Pull request closed