Skip to content

fix(updater): reload the supervisor after confirmed updates - #28

Merged
nixuuu merged 1 commit into
devfrom
fix/updater-supervisor-handover
Nov 3, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/updater-supervisor-handover

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 3, 2026

Copy link
Copy Markdown
Member

Standalone worker and gateway binaries run a resident supervisor that was never replaced: it kept the code of whatever version systemd started. On production it ran pre-#10 code for hours, so every second automatic update rolled back with "exit 75" until a manual restart.

Now, after a confirmed update, the supervisor asks the healthy child over IPC to hand over; the child uses the existing idle/drain mechanics (never interrupts work), exits with 76, and the supervisor process.execves the installed binary, keeping its PID (systemd/launchd need no changes). Unconfirmed candidates keep the rollback watchdog; no hand-over on rollback, on execve failure (logged, keeps running) or on Windows/without execve; a supervisor already matching the binary does nothing (no loops). Children under an older supervisor without IPC are unaffected. Docker, source and desktop installs are unchanged.

Tests: real compiled binaries A → B → C replace the supervisor code with the same PID; rollback, active work, replacement races, startup mismatch, no restart loop, execve failure. check:tmp 683 pass / 0 fail. Supervisors started before this version need one manual restart to load it.

@nixuuu
nixuuu merged commit ab05814 into dev Nov 3, 2026
2 checks passed
@nixuuu
nixuuu deleted the fix/updater-supervisor-handover branch November 3, 2026 17:29
nixuuu added a commit that referenced this pull request Nov 3, 2026
Since #23 each desktop artifact also carries
`package-sizes-<target>.json` (uploaded for the job log).
`publish-desktop` rejected it as "Unexpected desktop asset", so the
nightlies after #23/#28/#30 published server artifacts but no desktop
installers. The merge step now skips the size reports; the
update-metadata test covers it.
nixuuu added a commit that referenced this pull request Nov 18, 2026
## Change

When a gateway restart interrupts a worker binary download, it can also
interrupt the worker’s failure report. The gateway then keeps showing
the last download state and reissues the same command, which the worker
has already handled.

Keep an unacknowledged failure report in memory and resend it on the
update channel with the original command ID. The update center can show
the failure and let the owner retry the installation. Add gRPC
regression coverage and document the recovery behavior.

Related: #28

## Verification

- `bun run check:tmp ./tests/integration/updates.test.ts` passed all 20
tests. The regression test rejects the first failure report and verifies
delivery without another installation attempt.
- `bun run --filter '@canopy/worker' typecheck`, scoped lint and
formatting, and `git diff --check` passed.
- GitHub CI covers the full repository checks.
nixuuu added a commit that referenced this pull request Nov 21, 2026
## Problem

During two Linux worker updates, the candidate connected to the gateway
and confirmed startup at WorkerLink Welcome. The resident supervisor
then requested handover. The candidate started processing the
archived-thread snapshot as it was shutting down, waited for cleanup,
and rejected the arriving configuration without validation issues. The
same binary applied the same configuration on its next start. Desktop
Remote uses the Electron updater and a local BFF in this mode.

## Change

- Give the resident supervisor a chance to request handover before the
candidate serves WorkerLink, replays the journal, or processes the
archived-thread snapshot.
- Keep local startup confirmation for the rollback watchdog. Report
update success through UpdateService once a worker is about to serve the
link. Report failures and rollbacks independently of WorkerLink.
- Use the existing handover IPC with supervisors from earlier releases.

Fixes: #28

## Verification

- The compiled Linux worker regression failed on the original code
because the candidate started archived-thread cleanup before handover.
It passed with the fix under the previous supervisor. The final worker
applied config v10 and started Codex while preserving the pending AVD
reservation.
- 30 integration tests passed through `check:tmp` across worker update
cleanup, shutdown, route migration, and the update service. After
rebasing on `dev`, all 22 update and handover tests passed again against
the updated binary build script.
- Worker, updater, and integration-test typechecks and lint on edited
files passed. Full verification is left to GitHub CI. The running
systemd service stayed on its installed release.
nixuuu added a commit that referenced this pull request Nov 25, 2026
## Problem

During the upgrade from 0.9.0-nightly.1 to 0.10.0-nightly.1, the new
gateway started serving at 08:07:18 UTC and announced the supervisor
handoff one second later. The handoff completed at 08:14:39 UTC. A
queued turn started during that interval. The logs identify the shutdown
interval but lack timing for individual cleanup steps.

## Changes

- Pause new turn admission and dispatch as soon as the gateway accepts
an update. Keep pending work in the durable queues and resume it after
restart or update failure.
- Have the first process of the new release confirm its listeners and
transfer supervision before serving client or worker RPCs or starting
background jobs. Preserve rollback and the fallback for supervisors that
do not request a handoff.
- Log any shutdown step still running after five seconds and record its
elapsed time once settled.

## Verification

- 51 tests passed locally with `check:tmp`, including the compiled
gateway handoff, the durable queue regression, and the live gateway
relocation tests.
- Gateway and integration typechecks, lint on edited files, and the diff
check passed locally. GitHub CI runs the full gate.

Fixes: #28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant