Deploy the Semaphore server on a merge to main (CP-40) #13
No reviewers
Labels
No labels
needs-info
needs-triage
ready-for-agent
ready-for-human
review
merge-ready
review
needs-fix
review
needs-human
review
needs-operator
review
needs-review
review
waiting
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
olympus/infra-cockpit!13
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "hermes/cp40-deploy-semaphore-on-merge"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements CP-40, the first slice of CP-39: a merge to
maindeploys the Semaphore server (143) through Forgejo Actions, with nobody at a terminal.The deploy.
deploy.ymlon push tomain, concurrencycockpit-deploywithcancel-in-progress: false,enable-email-notifications: true. It logs in ascockpit, runsmake semaphore-idle(waits up to 15 minutes for Semaphore's pool to be empty, then proceeds and says why), thenmake prod NONINTERACTIVE=1—snapshot guest service verify, each its own make, stopping at the first red one.The non-interactive gate.
guestplans to an artefact, judges it with the plan check's judge and applies only a judged artefact;service's check run is its gate. WithNONINTERACTIVEunset, the typed word still guards.make snapshottakespredeploy-<YYYYMMDD>-<HHMMSS>(UTC) on the vmid read from state, described with repository, commit and run, then deletespredeploy-*beyond the newest three by exact name. A failed snapshot stops the deploy before anything changes.plan.ymlonpull_request_target, nopaths:filter, workflow and judge frommain, the head's Guest Stack underhead/planned with-lock=false: red on any destroy or replace and on any failure to read.roles/journalsetsStorage=persistenton 143.Docs.
docs/deploy.md: the automated deploy, the plan check, the Operator's hand resolution of a conflict, rollback losses, reading a failure.Proved against PROD, not just offline
make guest-plan: No changes — the first merge's Guest step is a clean no-op.make guest-plan-checkwith the plan key andinfra-ci@pve!cockpit-plan: green against real state. With a temporaryunprivileged = false(reverted): red,FAIL proxmox_virtual_environment_container.semaphore would be destroyed or replaced; prevent_destroy refused the plan— the acceptance criterion's mechanism.make snapshot: tookpredeploy-20261105-121814on 143 through the real API;pct listsnapshotconfirms it.make semaphore-idle: logged in as admin, read/api/tasks, empty pool.make check: green, now includingmake plan-test(14 cases, real OpenTofu plans of a throwaway local Stack, plus the prune at two, three and four snapshots).Two defects came out of running it live, both fixed here: the prune deleted a snapshot when fewer than three existed, and the judge did not name a
prevent_destroyrefusal whose address tofu wrapped at eighty columns.Operator actions already done
PROXMOX_VE_ENDPOINT.COCKPIT_GUEST_PLAN_STATE_ACCESS_KEY_ID,COCKPIT_GUEST_PLAN_STATE_SECRET_ACCESS_KEY(the existingtofu-plan-state-semaphorepair from SL-13),PROXMOX_VE_PLAN_API_TOKEN(infra-ci@pve!cockpit-plan, recorded in olympus/infra-secrets#27).Still to come, after this merges
Marking
plan / guest-plan-check (pull_request_target)required (its context exists only once the workflow is onmain), and the throwaway replace/green pull requests that criterion 1–2 name.Closes nothing: CP-40 stays open until its merge-time criteria are seen.
Review started (round 1/5) on
32240bae63— reading the diff now.repo: olympus/infra-cockpit · pr: 13 · reviewed-head:
32240bae63· round: 1/5 · verdict: approveRecommendation: merge
Two ADVISORY findings, no BLOCKER. Neither touches behaviour; both are documentation.
Standards
Sources read:
AGENTS.md(§Toolchain, §Docs),docs/agents/issue-tracker.md,docs/environment.md, plus the smell baseline. No documented-standard breach and no smell above nit level in the diff.AGENTS.md:44docs/deploy.md:93-97— added by this same PR — requires exactly that: "the Operator has done the destroy or the replacement by hand, outside the deploy", "run from a checkout with the Operator's own.envand their typed word, notNONINTERACTIVE".AGENTS.mdis the file an agent reads first, so the two pages it now carries disagree about whether a hand deploy is allowed. Smallest fix: scope the AGENTS.md sentence to the ordinary path ("a merge deploys PROD; the one hand path is the conflictdocs/deploy.mddescribes").scripts/snapshot.sh:39stale_names() { # listing, keep, but the function takes only<keep>and reads the listing from stdin (--argjson keep "${1:-$KEEP}", called asstale_names "$KEEP"at :129 andstale_names 3in the tests). Called the way the comment documents, it breaks: passing the listing as$1givesjq: error: number (4) and object ({"data":[{"…}) cannot be subtracted(rc 5) instead of the names to prune. Smallest fix:# stale_names <keep>: the listing on stdin.Spec
Spec source: the PR body. CP-40 itself was not readable — this repo's tracker is Vikunja project 11 (
docs/agents/issue-tracker.md) and no Vikunja tool is wired into this session — so the PR's own statements are the contract I held the diff to.deploy.ymlon push tomain; concurrencycockpit-deploy,cancel-in-progress: false;enable-email-notifications: true.forgejo/workflows/deploy.yml:23-34cancel-in-progress: falsequeues behind a running run rather than cancelling itcockpit, thenmake semaphore-idle, thenmake prod NONINTERACTIVE=1deploy.yml:56-63semaphore-idlewaits up to 15 min for an empty pool then proceeds and says why; never redscripts/semaphore-idle.sh:22,750-787,Makefile:367-371TIMEOUT=${…:-900}, every failure path isproceed, only a missing URL isexit 2)snapshot guest service verify, each its own make, stopping at the first red oneMakefile:377-382guestapplies only a judged artefact;service's check run is its gate; withoutNONINTERACTIVEthe typed word still guardsMakefile:116-152,321-325snapshottakespredeploy-<YYYYMMDD>-<HHMMSS>UTC on the vmid read from state, prunespredeploy-*beyond the newest three by exact name, and a failed snapshot stops the deploy before anything changesscripts/snapshot.sh:40-41,100,127-137,Makefile:356-361plan.ymlonpull_request_target, nopaths:, workflow + judge frommain, head's Guest Stack underhead/planned-lock=false, red on destroy/replace and on any failure to read.forgejo/workflows/plan.yml:23-47refs/pull/13/headexists on the remote, so the head checkout resolvesroles/journalsetsStorage=persistenton 143semaphore/service/roles/journal/tasks/main.yml:20-27,site.yml:5docs/deploy.mdcovers the deploy, the plan check, the Operator's conflict resolution, rollback losses, reading a failuredocs/deploy.md§Before the merge, §After the merge, §The Operator's hand resolution, §Rolling back, §Reading a failuremake checkgreen, now includingmake plan-test(14 cases)Makefile:284,270-271No requirement missing, partial, or wrongly implemented. The two "still to come" items (marking
plan / guest-plan-checkrequired, the throwaway replace/green PRs) are declared deferred in the body and CP-40 is left open, so they are not findings here.Verified by my own hand
mise exec -- make checkat the head, in a worktree of32240ba: green — env pin and map, env tests,plan-test(14 cases, every oneok),tofu fmt -recursive -check.judge()forced toreturn 0in a copy →plan-testfails 5 assertions, includingthe deploy refuses a plan that would replace the Guestandnothing was applied … (want [a], got [b])andthe refused plan artifact was left behind. The suite is not passing by accident.prodstops at the first red step. Sandbox of the head'sMakefile+scripts/over a throwaway Stack,make prod NONINTERACTIVE=1 PROD_STEPS="snapshot guest"with an empty state:snapshotfailed (error: no vmid in state), make returned 2, andprod: make guestwas never printed. The Guest was not touched.NONINTERACTIVE=1reaches the sub-makes.make prod NONINTERACTIVE=1 PROD_STEPS="guest verify"→ theguestsub-make printedNONINTERACTIVE: the plan check judges the plan above in place of the word., applied, andprod: make verifyfollowed. (Command-line vars rideMAKEFLAGS.)bash -nclean onscripts/snapshot.sh,scripts/semaphore-idle.sh,scripts/tests/plan-check.sh;python3 -m py_compileclean onscripts/plan-check.py.refs/pull/13/headresolves to this SHA (git ls-remote);concurrency.cancel-in-progress: falseandon.pull_request_targetare documented behaviour for this forge version (15.0.9), as isenable-email-notifications— the deploy's queueing claim is not wishful.Not verified, and why
make snapshoton 143,make semaphore-idle's login and empty pool,make guest-plan-checkwith the real plan key andinfra-ci@pve!cockpit-plan, and the liveprevent_destroyrefusal. I hold no credentials for PROD and I do not touch it. Those four are the author's evidence, not mine.plan.ymlend to end. Noplan / guest-plan-check (pull_request_target)status exists on this head —get_commit_statusesshows onlypr-checks / check (pull_request), success in 17s. Apull_request_targetworkflow is evaluated from the default branch, so it cannot run until it is onmain. I read the YAML and syntax-checked the scripts it calls; I did not see the forge execute it.deploy.ymlend to end — it only runs on a push tomain.Recorded, not counted as a finding
plan.ymldeliberately checks out and plans the pull request's own HCL while holding the plan state key and the auditor token; Forgejo's own reference says "It is strongly recommended that workflows usingon.pull_request_targetdo not interact with the untrusted code from the pull request". The PR argues the trade-off and both credentials are read-only (GetObjectonprod/semaphore.tfstate,PVEAuditoron/pool/prod), so the blast radius is disclosure of read-only material, not a change to PROD. Accepted risk, stated here so it is on the record.Summary
AGENTS.md:44contradictsdocs/deploy.md:93-97on hand deploys (ADVISORY).The change is better for the repo with it than without it. Merge, and take the two doc nits whenever the next touch lands.