Repository navigation
panel: readiness-gate /api/health on Postgres (fix panel-roll 502s) - #21
Merged
Merged
Conversation
/api/health returned 200 immediately — the moment Next could answer an API
route — so the panel's canary (update{health_check="checks"}) promoted before
the app could serve pages/tRPC, and even with Postgres unreachable. Traefik cut
traffic to an alloc that 502'd on real requests → the panel-roll downtime
(measured ~11s of 502 across one roll).
Now it reports ready only once Postgres answers (SELECT 1, 2s cap under the 3s
check timeout), so the canary only promotes into a serving alloc — and the known
PG-connect roll failure mode can't promote a DB-less alloc either. A ready latch
keeps it green after first success so a steady-state DB blip can't flap the
running panel out of Traefik; safe because the panel job has no check_restart.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
A panel self-roll drops the UI briefly (measured ~11s of 502 across one roll, over ~44s). Root cause:
/api/healthreturned a static200the instant Next could answer an API route — long before the app can serve pages/tRPC, and even with Postgres down. The panel's canary promotes on this check (update { health_check = "checks" }), so it cut Traefik over to an alloc that 502'd on real requests.Fix
/api/healthnow reports ready only once Postgres answers (SELECT 1, 2s cap under the 3s Nomad check timeout):readylatch keeps it green after the first success, so a steady-state DB blip can't flap the already-serving panel out of Traefik. Safe because the panel job has nocheck_restart— a failing check only affects routing/promotion, never kills the running alloc.Scope
One file (
apps/dokploy/pages/api/health.ts). First lever of the panel zero-downtime work; measure the next roll after this before deciding whether overlap + sticky sessions are also needed.Validation
scripts/check.shgreen (server build, 529 tests, app-tsc unchanged). Needs live measurement post-roll.🤖 Generated with Claude Code