Repository navigation
fix(update): FluxOS's dependencies install beside the running FluxOS, and an update that does not answer is rolled back - #61
Conversation
… and an update that does not answer is rolled back A FluxOS update installs the new commit's production dependencies into `<root>.next` while the old FluxOS keeps serving: `npm ci` from the commit's lock, `npm install` when it has none, with the flags the node's own installs use (`--legacy-peer-deps` on legacy, npm's cache on /dat on ArcaneOS). Only once that install has finished is FluxOS stopped; the checkout fast-forwards to exactly that commit, the staged `node_modules` is renamed into place and the live one into `<root>.prev`, and FluxOS is started. FluxOS is down for the stop, two renames and the start. The install runs in its own process group with a 20 minute timeout, and a timeout stops the whole group. A failed or timed-out install, or a checkout with commits of its own, leaves FluxOS running untouched. A FluxOS that does not answer `/flux/version` with the new version within 10 minutes is stopped, the checkout reset to its commit, the previous `node_modules` renamed back, and the old version started. Running a command in a process group with a group-wide timeout moves out of cloudui_update.js into process_group.js, which both updates use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cabecinha84
left a comment
There was a problem hiding this comment.
Staging the install beside the running FluxOS is the right design, and the extraction into process_group.js is faithful. The CI is green and the 8 new tests pass for me. One blocker though, and a few smaller points.
Blocking: FluxOS can be left stopped after stop()
In updateFluxOs, nothing guarantees start() runs once stop() has run.
- In the
catchaftercheckoutCommit/swapInStagedModules,git reset --hard beforeis unguarded. If it throws,start()is never reached. - In the rollback path,
git reset --hard beforeandrestorePreviousModulesrun beforestart(), also unguarded.
I reproduced both with a stale .git/index.lock, written inside stop for the first case and inside answersWith (returning false) for the second. In both, updateFluxOs rejects and FluxOS stays stopped. Events were stop for the first and stop,start,stop for the second. The old flow always reached the start command, because runShellCommand returns the error instead of throwing, so this is a regression.
The rejection then leaves auto_update, and job_creator only has a finally, no catch, and there is no unhandledRejection handler. Best case the watchdog restarts and a later check brings FluxOS back. Worst case FluxOS stays down.
Please wrap everything after stop() so start() always runs (try/finally, with the reset/restore errors reported in the result), and add a test with the index.lock for both paths.
Not blocking, but worth a decision
- Empty
target_version. Ifgit show <target>:package.json | jqfails or times out,answersWith('')can never match, so a healthy update is rolled back after 10 minutes. A guard that skips the update when the version is empty would avoid that. - No memory of a failed commit. A version that cannot start on a node repeats stage, stop, up to 10 minutes down, rollback on every auto-update cycle. Is a backoff or a remembered bad commit wanted?
npm ciis strict wherenpm installwas tolerant. If a FluxOS lock ever gets out of sync with its package.json, nodes silently stop updating, with only a console.log. Does the flux repo CI runnpm ci? Otherwise a fallback tonpm installmay be worth it.- Longer blind window.
auto_updatecan now take about 30 minutes (20 staging plus 10 waiting), and the watchdog does no checks in that time. Scheduling is chained so there is no overlap, but it is worth knowing. - Disk space. Two extra copies of
node_modulescan exist at once (.nextand.prev), with no free space check. - Removed sleeps. The 5 s sleeps between stop and start are gone, including the ArcaneOS one. Please confirm an immediate
systemctl startafterstopis safe there. - Real node test. The table drives
updateFluxOsdirectly, not throughauto_updateunder the service, so the full cycle is not covered.
Checked and fine: FluxOS master has no postinstall, no file: dependencies and no .npmrc, so installing in a separate directory is safe.
What
A FluxOS update installs the new commit's production dependencies into
<root>.nextwhile the old FluxOS keeps serving:npm cifrom the commit's lock, ornpm installwhen the commit has none, with the flags the node's own installs use (--legacy-peer-depson legacy, npm's cache on/daton ArcaneOS). Only once that install has finished is FluxOS stopped. The checkout fast-forwards to exactly that commit, the stagednode_modulesis renamed into place and the live one into<root>.prev, and FluxOS is started. FluxOS is down for the stop, two renames and the start.The install runs in its own process group with a 20 minute timeout, and a timeout stops the whole group, so no npm is left running on its own. A failed or timed-out install leaves FluxOS running untouched; so does a checkout with commits of its own, which is skipped before anything is staged. A FluxOS that does not answer
/flux/versionwith the new version within 10 minutes is stopped, the checkout reset to its commit, the previousnode_modulesrenamed back, and the old version started.Running a command in a process group with a group-wide timeout moves out of
cloudui_update.jsintoprocess_group.js, which both updates use. The version goes to 6.10.0 so nodes take it.Testing
npm cifrom 8.25.0's lock with and without--legacy-peer-depsinstalls identical trees.updateFluxOswith each node's own stop and start commands, from 8.24.0 to 8.25.0:node_modulesbackBoth nodes then ran this watchdog: it starts and holds for FluxOS as before.
🤖 Generated with Claude Code