Skip to content

fix(update): FluxOS's dependencies install beside the running FluxOS, and an update that does not answer is rolled back - #61

Open
MorningLightMountain713 wants to merge 2 commits into
masterfrom
fix/fluxos-staged-install
Open

MorningLightMountain713 wants to merge 2 commits into
masterfrom
fix/fluxos-staged-install

Conversation

@MorningLightMountain713

@MorningLightMountain713 MorningLightMountain713 commented Nov 27, 2026 •

Copy link
Copy Markdown

What

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, or npm install when the commit 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, 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/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. The version goes to 6.10.0 so nodes take it.

Testing

  • Unit (chud): lint and format clean, 77 tests passing, 8 of them new for the update. Three mutations each fail them: a timeout that signals only the first process (the update hangs on npm's child), FluxOS stopped before staging (5 tests), and no rollback (the rollback test).
  • npm ci from 8.25.0's lock with and without --legacy-peer-deps installs identical trees.
  • Real nodes, driving updateFluxOs with each node's own stop and start commands, from 8.24.0 to 8.25.0:
legacy (pm2) ArcaneOS (systemd)
staging, FluxOS serving 4 s 34 s
FluxOS down 8.7 s 9.2 s
forced rollback 8.24.0 checkout and the same node_modules back same
left behind nothing nothing

Both nodes then ran this watchdog: it starts and holds for FluxOS as before.

🤖 Generated with Claude Code

… 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 Cabecinha84 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

  1. In the catch after checkoutCommit/swapInStagedModules, git reset --hard before is unguarded. If it throws, start() is never reached.
  2. In the rollback path, git reset --hard before and restorePreviousModules run before start(), 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. If git show <target>:package.json | jq fails 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 ci is strict where npm install was 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 run npm ci? Otherwise a fallback to npm install may be worth it.
  • Longer blind window. auto_update can 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_modules can exist at once (.next and .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 start after stop is safe there.
  • Real node test. The table drives updateFluxOs directly, not through auto_update under 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.

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.

2 participants