broker: auto-deploy on main — CI publishes ourcloud-broker per sha, a sudo-scoped installer on the mail droplet, a deploy workflow on the workstation runner (the ADR 0185 rail for the broker) #688

Closed
opened 2026-08-23 04:02:00 +00:00 by ben · 2 comments
Owner

Why

Every broker fix the swarm lands (#647 deploy, b415707 for #672, c4d0bbc today) has needed a human ! to reach broker.idss.nz: build on a laptop, scp over the Netbird door, sudo install + systemctl restart on the mail droplet. In the phase-4 rehearsal loop that is the ONLY remaining hands step between a swarm-landed broker fix and the drive re-firing — today it cost ~2 h of wall-clock twice. The agent already rides a rail for this (ci.yml publishes agent-x86_64 per sha; ADR 0185 tracking pin). The broker should ride the same rail.

Deliverable

  1. CI publishes the broker. .forgejo/workflows/ci.yml: when broker/** (or go.mod/go.sum) changes on main, build ourcloud-broker (cd broker && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath ./cmd/broker) and publish it to the Forgejo generic package registry as idss-broker/<fullsha>/ourcloud-broker-x86_64, mirroring the agent's publish step. The version string already comes from broker.Version.
  2. An install script on the droplet, owned by the repo. scripts/broker/idss-broker-install.sh (installed to /usr/local/sbin/idss-broker-install, root:755): idss-broker-install <fullsha> → download from the registry (anonymous read is fine — it is public-read today), verify non-empty and that strings carries the version, cp -a the running binary to /usr/local/bin/ourcloud-broker.bak-<oldsha>, install -m755, systemctl restart ourcloud-broker, wait ≤10 s for is-active AND a 200 from http://127.0.0.1:8090/v1/gateways/offer; on failure restore the backup, restart, exit non-zero. Keep the last 3 backups. Idempotent for an already-installed sha.
  3. A deploy workflow. .forgejo/workflows/broker-deploy.yml on the workstation runner (it is on the Netbird mesh): workflow_dispatch with a sha input and, after CI's publish job succeeds on main, an automatic run — ssh deploy@100.98.48.68 sudo /usr/local/sbin/idss-broker-install <sha>. SSH key = a NEW deploy user's key stored as a repo secret (BROKER_DEPLOY_SSH_KEY), not the dev user's.
  4. Droplet side — Ben's !, written up as a runbook in broker/README.md: create user deploy (no shell beyond the one command), install the script, one sudoers line: deploy ALL=(root) NOPASSWD: /usr/local/sbin/idss-broker-install *. The worker must NOT attempt it (no swarm substrate reaches the droplet — #445 caveat); it ships the recipe and files the hands step as a ready-for-human follow-up.
  5. docs/GOTCHAS.md entry: a broker change is not live until broker-deploy ran — check journalctl -u ourcloud-broker | grep 'broker booted' for the version before re-driving; STATUS.md lead.

Acceptance

  • Pushing a broker/** change to main produces a registry package for that sha (CI green).
  • workflow_dispatch of broker-deploy with that sha, once the droplet half is in place, ends with broker booted … version=… in the journal and offer answering — proven by one real run (Ben or the session-runner triggers it after Ben's !).
  • A deliberately broken binary (exits on boot) is rolled back by the script and the workflow goes red — proven in the script's own offline shell test against fake systemctl/curl, the way scripts/lib/*-lib.sh tests are done.
  • Nothing in this ticket touches the live drive machinery on either executor host.

Non-goals

Blue/green, multiple brokers, containerising the broker, changing the broker's env/credential layout (/etc/ourcloud/broker.env and the LoadCredential do-token drop-in stay as they are).

## Why Every broker fix the swarm lands (#647 deploy, `b415707` for #672, `c4d0bbc` today) has needed a human `!` to reach `broker.idss.nz`: build on a laptop, `scp` over the Netbird door, `sudo install` + `systemctl restart` on the mail droplet. In the phase-4 rehearsal loop that is the ONLY remaining hands step between a swarm-landed broker fix and the drive re-firing — today it cost ~2 h of wall-clock twice. The agent already rides a rail for this (`ci.yml` publishes `agent-x86_64` per sha; ADR 0185 tracking pin). The broker should ride the same rail. ## Deliverable 1. **CI publishes the broker.** `.forgejo/workflows/ci.yml`: when `broker/**` (or `go.mod`/`go.sum`) changes on `main`, build `ourcloud-broker` (`cd broker && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath ./cmd/broker`) and publish it to the Forgejo generic package registry as `idss-broker/<fullsha>/ourcloud-broker-x86_64`, mirroring the agent's publish step. The version string already comes from `broker.Version`. 2. **An install script on the droplet, owned by the repo.** `scripts/broker/idss-broker-install.sh` (installed to `/usr/local/sbin/idss-broker-install`, root:755): `idss-broker-install <fullsha>` → download from the registry (anonymous read is fine — it is public-read today), verify non-empty and that `strings` carries the version, `cp -a` the running binary to `/usr/local/bin/ourcloud-broker.bak-<oldsha>`, `install -m755`, `systemctl restart ourcloud-broker`, wait ≤10 s for `is-active` AND a 200 from `http://127.0.0.1:8090/v1/gateways/offer`; on failure restore the backup, restart, exit non-zero. Keep the last 3 backups. Idempotent for an already-installed sha. 3. **A deploy workflow.** `.forgejo/workflows/broker-deploy.yml` on the workstation runner (it is on the Netbird mesh): `workflow_dispatch` with a `sha` input and, after CI's publish job succeeds on `main`, an automatic run — `ssh deploy@100.98.48.68 sudo /usr/local/sbin/idss-broker-install <sha>`. SSH key = a NEW `deploy` user's key stored as a repo secret (`BROKER_DEPLOY_SSH_KEY`), not the `dev` user's. 4. **Droplet side — Ben's `!`, written up as a runbook in `broker/README.md`:** create user `deploy` (no shell beyond the one command), install the script, one `sudoers` line: `deploy ALL=(root) NOPASSWD: /usr/local/sbin/idss-broker-install *`. The worker must NOT attempt it (no swarm substrate reaches the droplet — #445 caveat); it ships the recipe and files the hands step as a `ready-for-human` follow-up. 5. `docs/GOTCHAS.md` entry: a broker change is not live until `broker-deploy` ran — check `journalctl -u ourcloud-broker | grep 'broker booted'` for the version before re-driving; `STATUS.md` lead. ## Acceptance - Pushing a `broker/**` change to `main` produces a registry package for that sha (CI green). - `workflow_dispatch` of `broker-deploy` with that sha, once the droplet half is in place, ends with `broker booted … version=…` in the journal and `offer` answering — proven by one real run (Ben or the session-runner triggers it after Ben's `!`). - A deliberately broken binary (exits on boot) is rolled back by the script and the workflow goes red — proven in the script's own offline shell test against fake `systemctl`/`curl`, the way `scripts/lib/*-lib.sh` tests are done. - Nothing in this ticket touches the live drive machinery on either executor host. ## Non-goals Blue/green, multiple brokers, containerising the broker, changing the broker's env/credential layout (`/etc/ourcloud/broker.env` and the `LoadCredential` do-token drop-in stay as they are).

swarm-claim host=elitebook-distributed-server-03 run=9104
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=9104 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #688 — status blocked

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 688,
  "status": "blocked",
  "commits": [
    "a8105b558af6a83516128767dcca5fa416c6101d"
  ],
  "changed_files": [
    "scripts/broker/idss-broker-install.sh",
    "scripts/tests/broker-install-test.sh",
    "broker/README.md",
    "docs/GOTCHAS.md",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash scripts/tests/broker-install-test.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A deliberately broken binary (exits on boot) is rolled back by the script and the workflow goes red — proven in the script's own offline shell test against fake systemctl/curl": "MET: scripts/broker/idss-broker-install.sh rolls back to the .bak-<oldsha> backup and exits non-zero; scripts/tests/broker-install-test.sh scenario 3 proves it (8/8 checks pass, exit 0)",
    "Nothing in this ticket touches the live drive machinery on either executor host": "MET: changed files are the install script, its test, and docs only — no drive/executor path touched",
    "Pushing a broker/** change to main produces a registry package for that sha (CI green)": "DEFERRED to #689 (ready-for-session): the publish-broker CI job lives in .forgejo/workflows/ci.yml, a protected path a worker cannot edit (#445); the exact YAML is in #689",
    "workflow_dispatch of broker-deploy with that sha ends with 'broker booted' in the journal and offer answering — proven by one real run": "DEFERRED to #689 (broker-deploy.yml, protected path) + #690 (ready-for-human: droplet deploy user + sudoers + BROKER_DEPLOY_SSH_KEY); the runbook is in broker/README.md and live proof needs Ben's ! plus a session"
  },
  "summary": "Landed the broker auto-deploy install leg (idss-broker-install.sh) with its offline rollback test, runbook, and GOTCHAS; the two .forgejo/ workflows are protected-path work filed as #689 (ready-for-session) and the droplet setup as #690 (ready-for-human).",
  "reason": "Deliverables 1 & 3 require editing .forgejo/workflows/ (ci.yml publish job + broker-deploy.yml), a protected path a worker cannot touch (rule 9 / #445 rolls it back and fails the run); deliverable 4 (droplet deploy user + sudoers + key) needs a human on the mail droplet no swarm substrate reaches. Both filed as follow-ups (#689 with the YAML to apply, #690 with the runbook). The worker-ownable half — the tested install leg, runbook, and hazard — is landed in a8105b558af6a83516128767dcca5fa416c6101d.",
  "blockers": [
    "#689 (ready-for-session): apply the publish-broker CI job + broker-deploy.yml to .forgejo/workflows/ (protected path)",
    "#690 (ready-for-human): the droplet one-time setup on 100.98.48.68 (deploy user, sudoers, BROKER_DEPLOY_SSH_KEY)"
  ]
}
**close-report** for #688 — status `blocked` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 688, "status": "blocked", "commits": [ "a8105b558af6a83516128767dcca5fa416c6101d" ], "changed_files": [ "scripts/broker/idss-broker-install.sh", "scripts/tests/broker-install-test.sh", "broker/README.md", "docs/GOTCHAS.md", "STATUS.md" ], "tests": [ { "command": "bash scripts/tests/broker-install-test.sh", "exit_code": 0 } ], "criteria": { "A deliberately broken binary (exits on boot) is rolled back by the script and the workflow goes red — proven in the script's own offline shell test against fake systemctl/curl": "MET: scripts/broker/idss-broker-install.sh rolls back to the .bak-<oldsha> backup and exits non-zero; scripts/tests/broker-install-test.sh scenario 3 proves it (8/8 checks pass, exit 0)", "Nothing in this ticket touches the live drive machinery on either executor host": "MET: changed files are the install script, its test, and docs only — no drive/executor path touched", "Pushing a broker/** change to main produces a registry package for that sha (CI green)": "DEFERRED to #689 (ready-for-session): the publish-broker CI job lives in .forgejo/workflows/ci.yml, a protected path a worker cannot edit (#445); the exact YAML is in #689", "workflow_dispatch of broker-deploy with that sha ends with 'broker booted' in the journal and offer answering — proven by one real run": "DEFERRED to #689 (broker-deploy.yml, protected path) + #690 (ready-for-human: droplet deploy user + sudoers + BROKER_DEPLOY_SSH_KEY); the runbook is in broker/README.md and live proof needs Ben's ! plus a session" }, "summary": "Landed the broker auto-deploy install leg (idss-broker-install.sh) with its offline rollback test, runbook, and GOTCHAS; the two .forgejo/ workflows are protected-path work filed as #689 (ready-for-session) and the droplet setup as #690 (ready-for-human).", "reason": "Deliverables 1 & 3 require editing .forgejo/workflows/ (ci.yml publish job + broker-deploy.yml), a protected path a worker cannot touch (rule 9 / #445 rolls it back and fails the run); deliverable 4 (droplet deploy user + sudoers + key) needs a human on the mail droplet no swarm substrate reaches. Both filed as follow-ups (#689 with the YAML to apply, #690 with the runbook). The worker-ownable half — the tested install leg, runbook, and hazard — is landed in a8105b558af6a83516128767dcca5fa416c6101d.", "blockers": [ "#689 (ready-for-session): apply the publish-broker CI job + broker-deploy.yml to .forgejo/workflows/ (protected path)", "#690 (ready-for-human): the droplet one-time setup on 100.98.48.68 (deploy user, sudoers, BROKER_DEPLOY_SSH_KEY)" ] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#688
No description provided.