Repository navigation
fix(ci): Deploy to Dev fails when the backend /health probe fails (#2995) - #3051
Merged
Merged
Conversation
) `curl -sf .../health && echo "Backend: OK"` under `set -e` never aborted: the left side of `&&` is exempt, so a failed probe skipped the echo and the run went green, and notify-failure never filed its incident. Replace it with a bounded poll (3 probes, 30 s cap each per #1230, 20 s apart) that prints filtered diagnostics -- and the #2578 STALE line, which this exit now pre-empts -- before `exit 1`. The leading `sleep 10` goes: compose `up -d` already waited for the backend to be Docker-healthy. The test runs the workflow's own Health section under bash and sh with stub curl/sleep/sudo/docker, and a literal copy of the pre-fix lines as the control that reproduces the false green.
…2995) A backend that never becomes healthy fails at `Restart` (compose waits on `service_healthy`); one compose saw healthy that then misses the host `:8000` probe fails at `Health`. Item 4 now names both, adds host-port reachability to the checks and points a STALE Health failure at item 5. "What this means" no longer implies a Health or seeding failure left the old code running.
The new exit pre-empts the Error check, so the Health branch prints the backend's state and log lines itself. The run log is public; the test now asserts the container state line and the filtered error line appear and an unfiltered log line does not. Mutation: replacing the filtered tail with a raw `docker logs --tail 50` turns both shells red.
) The removed `sleep 10` in the Health section was also the scheduler check's grace. `up -d` waits on the backend's health only, so it returns right after starting the scheduler; an immediate inspect reads `starting` and the warning would print on every healthy deploy. Live run 36327494118: scheduler Started 15:01:10.9, `Scheduler: healthy` at 15:01:21.2, ten seconds later. Poll the scheduler up to three times, 5 s apart (the same <=10 s window), stopping at the first healthy answer. Still warn-only (D-B1).
1 of 4 tasks
AndriiPasternak31
marked this pull request as ready for review
September 28, 2026 19:47
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.
Fixes #2995
Cause
deploy-dev.yml's=== Health ===step rancurl -sf http://localhost:8000/health && echo "Backend: OK"underset -e.set -enever aborts on a command on the left of&&, so a failed probe only skipped theecho. The script carried on, the job went green, andnotify-failurenever filed its incident.Scope (what this does and does not fix)
A backend that is never healthy already fails the deploy at
Restart.docker compose up -dwaits ondepends_on: condition: service_healthy(docker-compose.prod.yml) and exits withdependency failed to start: container … is unhealthy. Docker's healthcheck curls the same/health. The false green covered a narrower window: Docker reported the backend healthy at compose time, but the host:8000probe then failed (the backend crashed or flipped after its first passing probe, or the host-port path is broken). This PR does not claim that a failed migration used to go green on dev. The dev VM runs PostgreSQL, so/healthshows that the backend is serving. It does not show that migrations were applied.Fix
curl -fsS --max-time 30, 20 s apart. If all 3 fail, the script prints filtered diagnostics, then::error::andexit 1. The marker in~/.trinity-last-deployed-shais not written.seq, so it is plain POSIX sh;/healthcan stall past 10 s under GIL contention, bug: backend Docker healthcheck flaps to "unhealthy" under batch load (10s timeout too tight for 2 workers) #1230);docker inspectstate and at most 10error|exception|failedlines, never a raw log tail. It also repeats the bug(ci): Deploy to Dev fails on every submodule pointer bump — the superproject fetch recurses into the enterprise submodule before the PAT transport block runs #2578 enterpriseSTALEerror when it applies, because the new exit fires before the later Error check could announce it.sleep 10also gave the scheduler its grace period. The scheduler check now polls up to 3 × 5 s instead and stays warn-only.notify-failureissue body (item 4) now names both failure points:Restart(never healthy) andHealth(healthy, then not answering on the host port). It also tells the reader to check host-port reachability.docs/memory/learnings/2026-09-28-…) and atests/registry.jsonrow..github/workflows/, and no feature flow documents deploy-dev.Proof
tests/unit/test_2995_deploy_health_gate.pyruns the workflow's own Health slice under bash and sh with stubcurl/sleep/sudo/docker. A literal pre-fix control reproduces the false green. Result: 18 passed with-p randomly, and 110 passed acrosstest_2995/2204/2246/2578/2625at seeds 1 and 99999.origin/devbytes, 14 tests fail and 4 pass. The 4 that pass are the pre-fix control and the scheduler warn-only test.script:was extracted withyaml.safe_loadand run under bash, sh and dash, with=== Health ===asserted as reached. Two independent harnesses gave identical results:::error::=== Done ===script:. shellcheck on the extracted script reports 2 findings before and 2 after, both above the Health block, and 0 in the Health block.Unprovable until the first post-merge
Deploy to DevThe stubs stand in for several things that only a real run exercises: the real ssh-action transport and how the exit code propagates through it,
notify-failure'sif: failure(), a real 503 from a real curl, the enterprise-mounted paths, and real timing. The expected result on the first run after merge isBackend: OK,Scheduler: healthy, no WARNING, and a green job.Related: #2986 copies the same
curl … && echoline intodeploy-prod-nightly.yml. There is no file overlap, so the two PRs can merge in either order.Lane C (CI workflow): before merge this also needs
journey-smokeandfrontend-e2egreen on the PR.🤖 Generated with Claude Code