Skip to content

fix(cloudui): the update runs in the background, a stopped update leaves nothing behind, and a missing version file is updated - #54

Merged
MorningLightMountain713 merged 7 commits into
masterfrom
fix/cloudui-update-timeout
Oct 27, 2026
Merged

MorningLightMountain713 merged 7 commits into
masterfrom
fix/cloudui-update-timeout

Conversation

@MorningLightMountain713

@MorningLightMountain713 MorningLightMountain713 commented Oct 22, 2026 •

Copy link
Copy Markdown

The CloudUI update (npm run update:cloudui) downloads a release tarball of about 60 MB, which takes hours on a slow link. The watchdog starts it in the background and goes on with its checks. A check that finds an update still running does not start another. When the update ends, a failure is logged with its reason, and a success is checked against the release's hash.

The update has six hours, so the limit stops only a download that never finishes. It runs in its own process group. A timeout sends the group SIGTERM, so the update can remove its own files, and SIGKILL ten seconds later if anything is still running. A process the update leaves running after it exits is killed. A timed-out update's reason states the limit it ran with.

The update's temporary files go in /tmp/fluxwatchdog-cloudui, passed to it as TMPDIR, which is emptied before and after every run. A scratch directory that cannot be emptied or created fails the update with that reason before it starts. A run cut short by the watchdog itself stopping is cleared by the next run. On ArcaneOS /tmp is memory.

FluxOS's update script from RunOnFlux/flux#1884 on keeps its files in .cloudui/ under the FluxOS directory, does not read TMPDIR, removes its files when it is stopped, and gives up on a download that stops moving; the scratch directory and the time limit cover FluxOS versions before it.

A CloudUI directory without its version file has no installed hash, so it never matches the release and is updated, which writes the file.

Both callers, the first install and the update, go through cloudui_update.js. Its tests cover the scratch directory, a leftover from an earlier run, a scratch directory that cannot be created, a timeout stopping every process the update started, SIGTERM letting the update remove its files before the group is killed, SIGKILL for an update that ignores SIGTERM, the time limit in the failure reason, a process left running after the update exits, a failed update, an update ended by a signal, a command that cannot start, a background start returning before the update ends, no second update while one runs, a new one after it ends, and an update whose completion handler throws; each is checked by breaking that part separately. Tests, lint and format pass on Linux (node 22).

Also run on an ArcaneOS node (systemd) and a legacy node (pm2), with FluxOS before and after #1884: a slow install in the background while the loop's checks went on, a second check finding the update running, a stop under pm2 mid-download leaving nothing behind, and a timeout ending in SIGTERM and the update's own cleanup.

🤖 Generated with Claude Code

@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.

ack.

Non-blocking comments (worth a review comment)

  1. The update can now block the watchdog loop for up to 10 minutes. auto_update() runs inside job_creator(), so on a
    slow node flux_check() waits up to 10 minutes instead of 2, plus the existing 25 seconds of sleeps. This happens at
    most once every 1 to 4 hours, so it's an acceptable trade-off, but the reviewers should know about it.
  2. A kill at the wrong moment can still leave no CloudUI until the watchdog restarts. The script runs rm -rf CloudUI
    and then cp. If the timeout fires between those two steps, the directory is gone. checkCloudUI() runs only once per
    process because of cloudUIChecked, and the auto_update check needs the directory to exist. So CloudUI stays
    missing until the watchdog restarts. This was already true before the PR, and the window is tiny because the
    timeout almost always fires during the download. A follow-up could reset cloudUIChecked when the directory
    disappears. Optional.
  3. Cosmetic: if something outside the watchdog kills the update with a signal, the log says exited with code null. It
    could use result.signal.
  4. The version bump was reverted in the second commit ("set at release"). Remember to bump package.json when you cut
    the release.

@MorningLightMountain713

Copy link
Copy Markdown
Author
  1. Accepted.
  2. A missing CloudUI is reinstalled at the next update check, not only at restart: auto_update() calls await checkCloudUI(); (watchdog.js:1026), which installs whenever the directory is absent. fix(cloudui): an update switches CloudUI atomically, gives up on a download that stops moving, and the installed release tag is in /flux/info flux#1884 removes the window itself: CloudUI becomes a symlink switched to each new build by an atomic rename.
  3. Done in 650da1d: an update ended by a signal logs killed by <signal>.
  4. The version is set in one release commit after fix(sync): the explorer sync check runs on mainnet only #51, fix: update fluxd or fluxbench only when apt can install it #52 and fix(cloudui): the update runs in the background, a stopped update leaves nothing behind, and a missing version file is updated #54 merge.

@MorningLightMountain713 MorningLightMountain713 changed the title fix(cloudui): the update gets ten minutes, a stopped update leaves nothing behind, and a missing version file is updated fix(cloudui): the update runs in the background, a stopped update leaves nothing behind, and a missing version file is updated Oct 25, 2026
…thing behind, and a missing version file is updated

The CloudUI release tarball is about 55 MB, so the update now has ten minutes
instead of two. It runs in its own process group, and a timeout kills the whole
group, download included.

The update's temporary files go in /tmp/fluxwatchdog-cloudui (its TMPDIR),
which is emptied before and after every run. On ArcaneOS /tmp is memory.

A CloudUI directory without its version file has no installed hash, so it is
updated like an out-of-date one, which writes the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ter a grace period

The update script removes its own files when it is stopped with SIGTERM, which
SIGKILL does not allow. A timeout now signals the group with SIGTERM and kills it
10 seconds later if it is still running. The group is not killed when the first
process exits after a timeout, because npm exits on SIGTERM while the script below
it is still removing its files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a six-hour limit

The watchdog's loop starts the CloudUI update and goes on with its checks rather
than waiting for a download that takes hours on a slow link. A check that finds an
update still running does not start another. When the update ends, a failure is
logged with its reason, and a success is checked against the release's hash.

The time limit is six hours, a 60 MB download at under 3 KB/s, so it stops only a
download that never finishes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed update

An error emptying or creating the scratch directory is returned as the update's
result, with its reason, instead of being thrown before the update has started,
so a background update reports it and the next one can start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The update's result carries its time limit, and the failure reason states that
limit rather than the default one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MorningLightMountain713
MorningLightMountain713 merged commit 92b3feb into master Oct 27, 2026
3 checks passed
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