feat(health): the UI can now report that it cannot do its job - #334
Conversation
The UI half of the healthcheck audit. The container healthcheck was a TCP connect — completed by the kernel's listen backlog while uvicorn is wedged, the scheduler is dead or the database is unreadable — and the docs claimed both images verify 'the app inside is actually answering', which was only true of the worker after #330. Meanwhile the bell's 'All collectors healthy' renders from a latch that can never go false once set, so a dead scheduler left every signal affirmatively green with week-old numbers underneath, indefinitely. - GET /api/health (unauthenticated — the Docker healthcheck asks it, and it is registered in the anonymous-rejection test's PUBLIC list with its reason): 503 + fixed problem names when the scheduler is stopped, when no collection has COMPLETED within 2.5x the interval, or when the database cannot be read. The stamp measures completion, not success — and a wedged collection lock freezes it, because the skip path returns before the finally: the wedge the skip line used to disguise as routine is now the thing this detects. Reason strings are fixed state names; exception text never reaches the response. - Dockerfile healthcheck asks that endpoint via http.client (urlopen honors http_proxy with no localhost exemption — the worker lesson), with an explicit 200 check. Verified to parse intact in a real docker build. - The bell goes 'No collection in N minutes — status unknown' when the server-computed staleness flag is set, instead of affirming health from the permanent latch. 9 new tests incl. negative controls (fresh stamp healthy, lock-skip does not advance the stamp, no exception text in the unauthenticated body). Full suite 4673 passed, coverage 96.56%.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThe application now exposes unauthenticated health status, tracks collection completion freshness, reports stale collector data in the UI, and uses the health endpoint for Docker health checks. ChangesHealth monitoring and collection freshness
Estimated code review effort: 3 (Moderate) | ~25 minutes Mergeability Score: ⚪ Minimal · up to The PR adds explicit UI health reporting, stale-collection detection, and a Docker healthcheck response so failures are surfaced instead of appearing healthy; no actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #334 +/- ##
==========================================
+ Coverage 95.58% 95.62% +0.04%
==========================================
Files 51 51
Lines 6946 6969 +23
==========================================
+ Hits 6639 6664 +25
+ Misses 307 305 -2
🚀 New features to boost your workflow:
|
|
@coderabbitai review |
|
|
@coderabbitai review |
|
|
@coderabbitai review |
|
|
@coderabbitai review |
|
|
@coderabbitai review |
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Why
The UI half of the healthcheck audit. Its container healthcheck was a TCP connect — completed by the kernel's listen backlog while uvicorn is wedged, the scheduler is dead or the database is unreadable — and
docs/guides/prometheus-metrics.mdclaimed both images verify "the app inside is actually answering", which after #330 was only true of the worker. Separately, the bell's "All collectors healthy" renders from a latch that can never go false once set: after a scheduler death, every signal stays affirmatively green — green worker dots (a frozen status column), a healthy bell, week-old balances that look identical to fresh ones — indefinitely.What
GET /api/health(unauthenticated — the Docker healthcheck has no credentials; registered in the anonymous-rejection test'sPUBLIClist with its reason). Answers three concrete operational questions and 503s with fixed state names:scheduler stopped,no collection completed in N minutes(2.5× the interval — one slow run plus one missed slot of flap resistance),database unreadable. Exception text never reaches the unauthenticated body, and there is a test pinning that.finally. A wedged collection lock freezes it, because the skip path returns before the finally: the wedge that"Collection already in progress, skipping"used to disguise as routine is now exactly what this detects.http.clientwith an explicit 200 check (urlopenhonorshttp_proxywith no localhost exemption — the worker-side lesson from fix(worker): report unhealthy when the worker cannot reach the UI #330's review). Verified to parse intact in a real Docker build.collection_staleflag is set it renders "No collection in N minutes — status unknown" instead of affirming health from the permanent latch.Testing
node --checkclean; the anonymous-rejection sweep (87 routes) passes with the one documented exemption.Summary by CodeRabbit
New Features
Bug Fixes