-
Notifications
You must be signed in to change notification settings - Fork 54
feat: Add health check endpoints for deployment verification #948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #948 +/- ##
==========================================
+ Coverage 86.88% 87.02% +0.14%
==========================================
Files 35 36 +1
Lines 3759 3800 +41
Branches 767 774 +7
==========================================
+ Hits 3266 3307 +41
Misses 355 355
Partials 138 138
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:
|
mod_health/controllers.py
Outdated
| db.remove() | ||
| return {'status': 'ok'} | ||
| except Exception as e: | ||
| return {'status': 'error', 'message': str(e)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to just dump the exception message here, it might contain sensitive information. Better log the exception and return a generic error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Fixed - now logging the exception server-side with g.log.exception() and returning a generic "Database connection failed" message to the client.
|
Also, you might want to rebase the branch :) |
Add /health, /health/live, and /health/ready endpoints to enable deployment verification and monitoring: - /health: Returns 200 if database and config checks pass, 503 otherwise - /health/live: Always returns 200 if Flask is responding (liveness probe) - /health/ready: Same as /health (readiness probe) These endpoints are essential for implementing safe deployments with automatic rollback - the deployment pipeline can verify the app is healthy after deploying new code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Log database exceptions server-side with g.log.exception() - Return generic "Database connection failed" message to client - Add comment explaining db.remove() connection pool cleanup - Update test to expect generic error message 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
ab0cf74 to
7f26810
Compare
|
Rebased on master and addressed review comments in the latest commit. CI is now running. |
g.log is only available during HTTP requests (set in before_request), but current_app.logger works in any app context including tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|



Summary
Adds health check endpoints to enable deployment verification and monitoring:
/health- Returns 200 if all critical checks pass (database, config), 503 otherwise/health/live- Liveness probe, always returns 200 if Flask is responding/health/ready- Readiness probe, same as/healthWhy This Is Needed
Currently, the deployment pipeline has no way to verify that a deployment was successful. If code is deployed that crashes on startup or can't connect to the database, the platform becomes "bricked" with no automatic recovery.
These endpoints enable:
/healthto confirm the app started successfullyTest Plan
/healthreturns 200 when database and config are OK/healthreturns 503 when database fails/healthreturns 503 when config is missing/health/livealways returns 200/health/readybehaves same as/healthExample Response
{ "status": "healthy", "timestamp": "2025-12-23T15:30:00Z", "checks": { "database": {"status": "ok"}, "config": {"status": "ok"} } }Related
This is part of a larger effort to make deployments more reliable. Future PRs will:
🤖 Generated with Claude Code