Repository navigation
fix(update): finish the Gateway restart a shipped pnpm updater refused - #201906
fuller-stack-dev wants to merge 12 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
…he finisher in its own scope
…eway-restart-after-shipped-driver
… gate hold on shipped drivers
…eway-restart-after-shipped-driver
…eway-restart-after-shipped-driver
|
Result of trying this change on the 2026.11.7 line (applied onto v2026.11.7 + #203401 with mechanical conflicts only; its unit test file passed 29/29 there). In real pnpm cells, published 2026.11.7 → that build and published 2026.11.6 → that build, the restart did not happen:
Started by hand after the updater had exited, the same logic did bring the Gateway back about 159 s later, then exited 1 with a missing module because the update it handed off to replaced the package it was running from. The cause of the early exit in the normal path is not established. This stays a draft; the promise it prints is not kept in its current form. |
|
Closing without merging. This finisher helped pnpm installs whose updater is 2026.11.5 through 2026.11.9, on an update to a release with the same database schema. Every release still to ship has a newer schema than those versions, so their updaters hand the rest of the update to the new release, which already includes the restart fix from #201735. 2026.11.10 includes that fix too. The same-schema updates this PR targeted can only land on releases that are already published, and those do not contain this code. A later test cell also showed that a finisher launched in a transient scope is stopped together with the updater's process tree. #204322 uses a transient service for its own recovery for that reason. Not measured: an update from 2026.11.9 straight to 2026.11.11. If a 2026.11.6 to 2026.11.9 pnpm install still ends with the Gateway stopped after updating to 2026.11.11 or later, please open a new issue with the update output and |
What Problem This Solves
A pnpm install updated by published 2026.11.5 to a release with the same database schema (2026.11.5 → 2026.11.6) keeps a working
openclawcommand. Since #201735 the Gateway stays down:openclaw updateexits 1 withservice-revalidation-failed, and the restart and the recovery restart are refused withmanaged-service-ownership (service-ownership-changed). In a real cell the Gateway stayed down for 402 s, until the user ran another command.Root cause, in the installed updater, which this change cannot patch:
update-command-service-revalidation.ts:333-398at v2026.11.5).mainfixed this check (fix: keep the openclaw command and Gateway working after updating a pnpm install #201735), but only a fixed updater runs it. 2026.11.5 hands the remaining steps to the new package only when the schema migrated (update-command-migrated.ts:141-146at v2026.11.5).User Impact
On a same-schema pnpm hop driven by 2026.11.5, the Gateway now comes back on the new version without another command. The new package's Doctor, which that updater does run after the swap, prints one line saying OpenClaw will try to restart the Gateway after the updater exits. After the updater exits, a background process refreshes the service definition and starts the Gateway through the ordinary
openclaw gateway install --forceandopenclaw gateway startowners. The installed updater still prints its own failure and exits 1, because it decides that before this code can act.Why This Change Was Made
This is compatibility code for shipped updaters that cannot be patched. It applies to 2026.11.5 and earlier, and to 2026.11.6 and 2026.11.10 builds without the #201735 fix. The module comment names those versions, and the module is removed once no supported upgrade path starts from such an updater.
Two other routes were rejected:
dataAtRisk/no-rollback records and turn off the updater's own recovery.ExecStartover D-Bus (systemd-service-files.ts:204-222at v2026.11.5), so passing it would needdaemon-reload. The updater also spawns its Doctor with service repair and activation disabled.How it works:
src/flows/doctor-health-startup.tsacts only when all of these hold:service-revalidation-failed, and re-checks every gate under the Gateway service operation lock. It yields if a newer update started, if the service is running, or if the Gateway answers.openclaw gateway install --force, thenopenclaw gateway restart, oropenclaw triage. A real cell showed thatopenclaw gateway restartalone exits 78 in this state.Where the finisher runs. On Linux it is launched through
systemd-run --user --scope --collect --unit=openclaw-update-restart-<runId>.scope, using the managed-service handoff launcher's existingsystemd-runresolution (update-managed-service-handoff-launcher.ts). Without its own scope it would share the updater's cgroup and die with it. For a Gateway-started update, that cgroup is the transientopenclaw-update-<id>.service(KillMode=control-group, v2026.11.5update-managed-service-handoff-launcher.ts:49-76), which stops when its helper exits. The scope has noPartOf=on the Gateway, so the finisher's owngateway install --forcecannot stop it. Ifsystemd-runis missing, it falls back to a plain detached spawn. On macOS it is a detached process.Single instance. A per-run file lock. The existing owners were checked and none fits:
openclaw updatethe finisher must yield to, and the lease has no row kind for this;sqlite-live-ownerauthorizes only the Gateway's own database reads.What readers show after a successful finish. The stored run keeps
status: failed,reason: service-revalidation-failed, plus the verification and the warning row; no new field or status value was added.isRefusedRestartFinishedLater(src/infra/update-run-restart-finished.ts) recognizes that combination. With it:openclaw update statusleads with "✅ OpenClaw updated to 2026.11.6 (from 2026.11.5); 1 warning needs attention.";/updatesummary reads as updated;update status --jsonprints the stored record unchanged;Gateway-started updates. The shipped 2026.11.5 Gateway refuses
update.runfor a pnpm global-virtual-store install before changing anything (update.ts:427-432, install surfacepackage-root). So that path never reaches the finisher. That refusal also exists onmainand is handled in a separate PR.The docs correct the earlier claim that 2026.11.4 and 2026.11.5 always hand the later steps to the new package: they do so only when the schema migrates.
Evidence
Draft. Unit tests:
update-shipped-restart-finisher.test.ts, 14 tests, using a real update run ledger and a real pnpm store layout on disk. Each gate was removed in turn, and every case that guards it failed. Real Docker cells on the 2026.11.6 line (#201739 plus this commit) are running and will be added here:openclaw update5 s after the failure;The red cell is published 2026.11.5 → #201739 head
848912c: exit 1, the Gateway down for 402 s, and back only after a second update.Start layout covered. Every cell starts from a registry install made by
pnpm add -g, which puts the package instore/v11/links/@/openclaw/<version>/…. That is also where a user who recovered by hand withpnpm add -gends up, so a later update from such an install starts from the layout the cells already use. The target layout is the project-store layout the updater itself produces (global/v11/<group>/node_modules/.pnpm/openclaw@<version>…), which a real public-registry cell confirmed.Steps left to a person
None on the covered hop. If the finisher gives up, its warning names the verified recovery and
openclaw triage.Not proven yet
openclaw update→ published 2026.11.6 from the public registry only. The updater installs a registry target in the project-store layout (global/v11/<group>/node_modules/.pnpm/openclaw@<version>…), the same layout class the earlier tarball-target cells used. See fix(update): keep the openclaw command and Gateway working after a pnpm update #201739 (comment).virtualStoreType=projectsetting the updater passes, so its target layout may differ. A pnpm 11 cell is being prepared.KillUserProcesses=yesat logout. In the last case the nextopenclaw updateor the verified recovery heals the install.