Repository navigation
ci: nightly deploy of dev to the main internal instance (#2985) - #2986
obasilakis wants to merge 5 commits into
Conversation
|
✅ Nightly unit-suite clean when this PR is merged into |
/validate-pr — ❌ REQUEST CHANGESAll line refs are in Blocking
Should fix
OK: no hard-coded hosts/IPs/keys; the failure issue dedupes on title and has no log leak in its body; the Verification: the deploy |
Scheduled 04:00 UTC + manual. Same shape as deploy-dev.yml, plus a pre-deploy pg_dump and a skip when executions are running. Secrets are scoped to a production environment. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ease (#2985) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
c8e8f0a to
208ce6b
Compare
|
merge-train: ejected from this train — rides the next one once fixed. Blocking (all in
Needs an admin before merge: the Also worth addressing: carry over the #1443 submodule The earlier review's test finding is fixed ( |
AndriiPasternak31
left a comment
There was a problem hiding this comment.
Requesting changes on two small things. The rest is suggestions.
1. Inherits #2995 and poisons the skip marker (deploy-prod-nightly.yml:111). curl -sf .../health && echo " Backend: OK" doesn't abort under set -e. I ran the extracted script: block with a stubbed always-failing curl: exit 0 under bash and sh, and ~/.trinity-last-deployed-sha gets written. So the next night sees TARGET == LAST and skips. A broken prod stays broken with no retry and no alert. The enterprise grep catches an Alembic failure (that crashes at import, before the "registered" print) but not a lifespan failure, which happens after it. On Postgres, /health is liveness-only (main.py:1653), so this line is the only liveness gate.
curl -sf http://localhost:8000/health >/dev/null || { echo "::error::backend unhealthy after deploy"; exit 1; }2. The pre-deploy backup check can't fail (:76-77). With no pipefail, a failed pg_dump still leaves a valid 20-byte gzip that passes gzip -t && [ -s ]. Reproduced: exit 0, empty dump, then it migrates prod. set -eo pipefail on :50 fixes it (re-ran: exit 1). A content check (the PostgreSQL database dump complete trailer) would be better still.
Suggestions, not blocking:
- Deploy
dev-green, not the dev tip. #2945's tag andscripts/ci/dev-last-green.share on dev now. The tip can be a 03:59 merge Tier 2 hasn't seen, anddeploy-dev's cron fires at the same 04:00.git checkout --detach "$TARGET_SHA"instead ofpullalso removes the fetch→pull race between:57and:82. - Move the in-flight check to just before
up -d. It runs before a multi-minute build, and anything that starts in that window gets killed. Also, repeated skips are a silent green. Consider alerting after N skipped nights. productiondoesn't exist yet, and GitHub creates it unprotected on first use. Addif: github.ref == 'refs/heads/main'on the job so this doesn't depend on the settings step.- Health-gate the scheduler (and MCP) too. Only the backend is probed.
- Rollback: print the previous SHA before overwriting the marker, and put a checkout-prev/rebuild/restore-dump recipe in the failure issue. Also consider a host-side
flockagainst manual deploys, and assigning the failure issue. - Please edit the 1Password vault/item name out of the PR body. This repo is public.
I verified both blockers with a stubbed run of the extracted block. Happy to re-review once they're in.
|
Correction to blocker 2: don't add Scope it to the dump instead: ( set -o pipefail; sudo docker exec trinity-postgres pg_dump -U trinity trinity | gzip > "$DUMP" )Blocker 1's |
|
The fix for blocker 2 (the Please use the same block in |
dolho
left a comment
There was a problem hiding this comment.
/review — #2986 (re-review): changes still required
The head is 208ce6b and hasn't changed since 2026-09-24. The blockers from Andrii's changes request and the 09-23/09-25/09-27 comments are still open. The PR merges cleanly with dev (26 commits behind).
Prior review items
| # | Item | Resolved? |
|---|---|---|
| B1 | A failed health check doesn't fail the run, and the SHA marker is still written | No: :111 curl -sf http://localhost:8000/health && echo " Backend: OK" |
| B2 | The backup check passes on a failed pg_dump (no pipefail) |
No: :76-77 unchanged. Use the subshell-scoped ( set -o pipefail; … ); a script-wide one breaks the grep -q enterprise check. |
| V4 | The in-flight execution check runs before a multi-minute build | No: the check is at :67, up -d at :104 |
| — | test_2814 trigger parity |
Yes (ACCEPTED_UNTIL_RELEASE rows) |
| S | Deploy --detach $TARGET_SHA rather than pull; carry over #1443's submodule line and #2204's backup-container reaper; main-only job guard; health-gate the scheduler and MCP; print the previous SHA and a restore recipe; host flock |
No |
| S | Up to 20 enterprise boot-log lines go to the public log (:118) |
No |
| S | The 1Password vault/item name is still in the PR body | No |
Critical
- The health gate cannot fail (10/10). Same line as B1. #3051 (now on
dev) replaced it indeploy-dev.ymlwith a 3-probecurl -fsS --max-time 30loop that exits 1. Port that block here so the two files match. - The backup check always passes (10/10). Same as B2. A 20-byte empty gzip passes
gzip -t && [ -s ], and prod then migrates with no real backup. - Secret exposure depends on repo settings, not code (8/10). The
productionenvironment doesn't exist yet, and GitHub creates it unprotected on first use. Any writer can runworkflow_dispatchfrom any branch, so without amain-only deployment-branch rule, a modified branch copy of this file can readPROD_SSH_KEY. Create the environment with that restriction before merging. A job-levelif:is only a backstop, since a branch copy can delete it.
Informational
- The marker records
HEADafterpull(:122), not theTARGET_SHAfrom:57, so the fetch→pull race can deploy a commit the skip check never saw. - The in-flight check only reads
schedule_executionsand hard-codes thetrinity-postgrescontainer and role. A mismatch fails red, which is the safe direction. ~/backupsuses the default umask and has no retention, so prod dumps accumulate.
Clean
No hosts, IPs or keys are committed. Actions are SHA-pinned and match deploy-dev.yml. There is no pull_request_target or untrusted-code path. permissions: contents: read. The failure issue dedupes on its title.
Required before merge: B1 (port #3051's health block), B2 (subshell pipefail), the in-flight re-check right before up -d, the production environment restricted to main, and the PR body edited.
…ploy dev-green (#2985) - Health: port deploy-dev's 3-probe block (#2995); gate scheduler + mcp-server health too - Backup: subshell-scoped pipefail on pg_dump, verify the dump-complete trailer, umask 077, 14-day retention - Re-check in-flight executions right before `up -d`; 3 skipped nights in a row fail the run - Deploy the dev-green tag (#2945) via detached checkout; marker records that SHA - Carry over #1443 submodule update=checkout and #2204 stale-container reaper - main-only job guard; no enterprise boot-log lines in the public log - Print previous SHA + backup path; rollback recipe in the failure issue Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Addressed in 63e81da. All in Blockers
Suggestions taken
Not done
Stub run of the extracted script: failing curl → exit 1, no marker. Failing pg_dump → exit 1. Running execution → skip (1/3), and the third skip → exit 1. Happy path → marker written. A 300 KB boot-log grep stays green. A repo admin still has to create the |
|
merge-train: not on this train. It rides the next one once fixed. Every code blocker from Andrii's review, dolho's re-review and the 09-25 train is fixed at Blocking:
Mechanical fixes:
Your call:
|
#2985) - Drop `set -o pipefail` from the pre-deploy dump: dash rejects it, so every run on a dash login shell reported "pg_dump failed". The trailer check is the gate; `||` still catches gzip failing. - Health failure prints a count of error-like backend lines, not the lines: the Actions log is public. - Header documents the trinity-postgres container assumption, the detached HEAD left on the host, and the POSIX constraint. - test_2985: runs the whole script under bash, sh and dash with stubs — happy path, health failure, failed dump, dump missing its trailer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Addressed at
Still blocking, needs an admin: create the |
|
@AndriiPasternak31, could you re-review? Your CHANGES_REQUESTED from 09-27 is the only thing blocking this. A merge-train check of the two commits since then says every point is addressed:
Still open, as small follow-ups:
Before release: a |
…mp trailer window (#2985) psql failing inside check_in_flight exited silently under set -e. It now prints ::error:: before exiting. The trailer check reads the last 20 lines, since pg_dump >= 17.6 appends a \unrestrict block after the trailer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Follow-ups from the last merge-train pass, at
@AndriiPasternak31 ready for re-review. Still needs an admin: a |
|
merge-train: validated READY on Not merged today for one reason: @AndriiPasternak31's CHANGES_REQUESTED from 09-27 (against The One follow-up worth an issue, not a blocker: when the second |
|
@AndriiPasternak31 could you re-review? Your 09-27 blockers look addressed at Pre-merge admin step: create a |
|
Change of direction before this lands: the nightly production deploy shouldn't live in this public repo. A deploy workflow for our own instance is internal tooling, and its script documents our production host layout to the world. Please move it to the private
The fixes from the 09-27 review carry over unchanged. |
|
@vybe moved to abilityai/trinity-enterprise#786.
Closing this PR once #786 is reviewed. |
AndriiPasternak31
left a comment
There was a problem hiding this comment.
Re-review at 2d7b005e. My 09-23 and 09-27 blockers are all fixed. I checked each one by running it, not by reading.
- Health gate.
:176-191makes 3 probes and exits 1, and the marker is written only at:214, after every gate. If I swap back tocurl -sf … && echo, 3 tests go red. Moving the marker above Health also turns 3 red. - Backup. The dump has to end with its trailer (
:125-130). Swapping back to the oldgzip -t && [ -s ]check turns 6 red (fail and truncated, under bash, sh and dash). - pipefail. There is no script-wide pipefail and dash runs clean. A failed psql query now stops the run with an
::error::(3 tests go red if that is removed). - Suggestions. All in, except the two you declined with reasons (
flock, assigning the issue):dev-greenwith a detached checkout and an ancestor check, the in-flight re-check beforeup -d, the 3-night alert, themain-onlyif:, the scheduler and MCP gates, rollback info, the #2204 and #1443 carry-overs, and no boot-log lines in the public log.
I'm leaving my review as is rather than approving. Per vybe's 10-03 call this workflow belongs in the private repo, and abilityai/trinity-enterprise#786 has the same behaviour: I diffed the two, and only comments and issue refs differ. Please close this PR. My remaining notes are for #786:
- The second in-flight check (
:168) can skip after checkout and build, and the run still ends green. The host is then left on the new SHA plus the new enterprise checkout while the old containers keep running. Prod bind-mounts./config/*and./src/backend/enterprise, so the old image serves new templates and enterprise source for up to 3 nights, and a crash-restart boots old OSS with new enterprise code. I reproduced this with your harness (psql returns 0, then 1): rc=0 with a::warning::only. Fix: restoreLAST_SHAand the submodule insideskip(), or build from a separate worktree. - Seven gates have no test. I deleted each one in turn and every test stayed green: the re-check, the 3-skip escalation, the scheduler/MCP gate, the
dev-greenancestor check, the stale-pin check, the enterprise-registration grep, and thetail -n 20window. The stub's trailer sits on line 5 of 6, sotail -n 5also passes. Each needs only one new stub mode on the existing harness. - Tailscale pin.
:46is pinned to v4.1.3;deploy-dev.ymlondevuses v4.2.0. - Before #786 merges, create
productionrestricted tomain, then add the secrets. Otherwise the first scheduled run creates the environment with no protection.
Housekeeping:
|
Superseded by the private-repo port (trinity-enterprise#786). Closing unmerged so only one deploy-prod workflow targets the host. |
Closes #2985
New
.github/workflows/deploy-prod-nightly.yml: runs at 04:00 UTC, and onworkflow_dispatch. Job only runs frommain.Order of steps: resolve the
dev-greentag (#2945) → skip if already deployed → skip if an execution is running →pg_dump(trailer-verified) → detached checkout of that SHA → enterprise stale check → build with--pull→ reap stale compose containers (#2204) → re-check in-flight executions →up -d(enterprise overlay) → health gate on backend, scheduler, MCP → enterprise registration grep → write the deployed-SHA marker. Three skipped nights in a row fail the run. A failed run files one deduped issue. It deliberately does not use thedeploy-failurelabel, so it can't silence dev's alerts.Needed before it can run (admin / ops):
productionenvironment with deployment branches restricted tomainPROD_HOST,PROD_USER,PROD_SSH_KEYmain🤖 Generated with Claude Code