Repository navigation
fix(cloudui): an update switches CloudUI atomically, gives up on a download that stops moving, and the installed release tag is in /flux/info - #1884
Conversation
Cabecinha84
left a comment
There was a problem hiding this comment.
Conditions before merge
- Rebase onto current development with the resolution above.
- Run the harness gate at the rebased head.
Non-blocking notes
- .eslintignore: it still has /CloudUI/, which does not match a symlink. The PR changed .gitignore for this reason, so
it should do the same here. - Rebuild route: rebuildUi now has no time limit. It can also queue behind a watchdog run holding the flock, leaving
an HTTP request open for hours on a slow link. - Second waiting run: a run that waited on the lock downloads again after the first finishes, without checking whether
it is already current. - Platform: the script now requires flock and GNU mv -T, which is fine on Linux nodes.
… and a failed or killed run leaves only the installed build Each build is unpacked into its own folder under .cloudui/, and CloudUI is a symlink to it, moved to a new build by renaming a new symlink over the old one. A CloudUI that is still a folder is swapped for the symlink with mv --exchange where mv has it, and moved aside then replaced where it does not. Every run removes everything in .cloudui/ but the installed build when it exits; runs take a lock so one never removes another's download. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getFluxInfo asks Docker and MongoDB for their versions. The tests now stub both and check the versions reported, so they pass or fail on getFluxInfo alone, whether or not a Docker daemon is running where they run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…flux/info
The update script writes the release tag to `tag` beside `version` in the build
it installs, so the tag switches with the build. `version` keeps the release
asset's sha256, which the watchdog and FluxOS compare with the release.
/flux/info reports `cloudUI: { tag, sha256 }`, each null where the script has not
written it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ow one runs to the end Both curl calls give up when the transfer stays under 1 KB/s for two minutes or the connection does not open within 30 seconds. The run then fails and removes its files, keeping the installed build. A slow transfer that keeps moving has no time limit, so callers need not set one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A service manager stopping a service signals every process in it until no new ones appear, which includes the processes the cleanup starts. The cleanup ignores SIGTERM, SIGINT and SIGHUP, and the processes it starts inherit that. The reader of the run's output may have stopped with the service, so the cleanup also ignores SIGPIPE and removes the files before it logs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… no time limit On a node without the watchdog, FluxOS checks CloudUI at boot. The check now starts in the background, so a slow download holds up nothing that starts after it. The script runs with no time limit, since it gives up on a download that stops moving, and only the end of its output is kept for the log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…files bash dies outright on a second terminating signal that arrives while it handles the first, before its EXIT trap runs, and a service manager sends SIGTERM more than once. The script catches SIGTERM, SIGINT and SIGHUP, ignoring further ones, and exits through the EXIT trap. It catches SIGPIPE too, so a write to a reader that has stopped fails instead of killing bash; the commands it runs start with the signal at its default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on its own A signal sent as the cleanup starts, a stop during a failed run's cleanup, and a write after the output's reader has gone are each produced at that point, so the tests do not depend on timing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…it on within() clears its timer once the run or the timeout settles, so the file leaves no timer pending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The preparation asks docker which app networks exist before it lets a private caller through. The tests answer with one network the caller is not on, so they pass or fail on the preparation alone, with or without a docker daemon where they run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…whatever CloudUI is Both ignore files name the two paths the update script owns, anchored to the project root. /CloudUI has no trailing slash, so it matches the symlink as well as a folder, and .cloudui/ is listed rather than left to eslint's dot-folder default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in progress The update script takes --if-idle: a run started with it does not wait for the run that holds the lock, and exits 75 having changed nothing. The rebuild route runs the script that way, through rebuildIfIdle, and answers that an update is in progress, rather than holding the request until the other run and then its own download finish. While this process has a run in flight, rebuildIfIdle answers busy without starting one. The boot check and the watchdog still wait their turn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uild installs it again The update script does not download a release whose sha256 CloudUI/version already holds, and exits 0. --force installs it again. A run that waited for another to finish finds that run's release installed and stops there. The rebuild route passes --force, so it still repairs a damaged CloudUI whose version file names the release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… as it is Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the policy The node refuses a registration before resolving its repotag until it holds the policy, so test 1 waits for the shaped node's policy:bundleChanged as well as its lookup of the policy host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73224dd to
a5496d0
Compare
|
Thanks for the review. Both conditions and the four notes: Rebase: the branch is on current Gate: tester,
Units on chud ( |
… version and tag The boot check counts a CloudUI with nothing but its version and tag files as missing, and that version file still names the latest release, so the script's already-installed check would stand down. The boot check's install passes --force. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cabecinha84
left a comment
There was a problem hiding this comment.
ACK at head 2a9002c (2nd pass)
I test-merged the head onto current development (8c8d3bf, which includes #1919 and #1920). It merges cleanly, and the PR is mergeable with CI green.
Verified
- Full unit suite on the merge: 13425 passing, 0 failing, 2 pending. One pending is the new
mv --exchangetest, which skips itself on coreutils 9.4 (my machine), so the folder-to-symlink swap via--exchangewas not run here; the fallback path is covered and passes. - eslint is clean on the touched files, and
bash -npasses on the script. - Serving through the symlink: I pointed
express.staticand thesendFileSPA fallback at aCloudUI -> .cloudui/build.xlink./version, assets,/and an SPA route all return 200. - The boot check is fire-and-forget, and
checkAndUpdateCloudUIhas an outer try/catch, so there is no unhandled rejection.app.jshas no boot-time gate onCloudUI.
My earlier points are all closed: the rebase, .eslintignore, the rebuild route's --if-idle (it answers "in progress" at once), the skip-if-installed check, and the platform note.
Left, none blocking
- Harness gate at this head. The author's gate was at 112c9271c, before 2a9002c. That commit is JS and unit tests only, and no harness suite references CloudUI.
- On hosts without
mv --exchange, a catchable SIGTERM between the two fallbackmvs runs the cleanup withCloudUIabsent, and the cleanup also deletesprevious.*. The window is microseconds and happens once per node, and the boot check reinstalls a missingCloudUI. Ignoring signals across the pair would close it. remove_unused_buildsassumes a relativeCloudUIsymlink. A hand-made absolute link into.cloudui/would leave the installed build unprotected. The script itself always creates relative links.- Watchdog follow-up, not for this PR: a watchdog run while
versionstill matches is now a silent exit 0, so any content repair there needs--force.
Cabecinha84
left a comment
There was a problem hiding this comment.
Approving at head 2a9002c, per the ACK review above. The harness gate at this head is still outstanding (non-blocking).
|
Thanks for the second pass. The four notes:
|
What changes
scripts/update-cloudui.shinstalls each build into its own folder under.cloudui/, andCloudUIbecomes a symlink to the installed build. An update renames a new symlink over the old one, soCloudUIalways resolves to a complete build, the old one or the new one.CloudUIis still a folder): swapped for the symlink in one step withmv --exchangewhere mv has it (coreutils 9.5+); where it does not, the folder is moved aside and the symlink renamed into its place. Every later update is a symlink-over-symlink rename on every system..cloudui/. When a run exits, for any reason, it removes everything there except the installed build. A run killed outright with SIGKILL leaves its files for the next run to remove.flockon.cloudui/.lockand wait their turn. With--if-idlea run does not wait: when another run holds the lock it exits 75 and changes nothing. The downloads close the lock descriptor, so a download that outlives its killed shell does not block the next run.CloudUI/versiondownloads nothing and exits 0, so a run that waited for another finds that run's release installed and stops there.--forceinstalls it again..cloudui/on disk rather than/tmp.CloudUI/version,CloudUI/index.htmland every other path readers use are unchanged;express.static,sendFile,existsSyncandreaddirSyncall follow the symlink..gitignoreand.eslintignore:/CloudUI(no trailing slash, so it matches the symlink as well as a folder) and/.cloudui/, anchored to the project root.flockand GNUmv -T(Linux).FluxOS's own update (nodes without the watchdog)
At boot FluxOS starts the CloudUI check in the background (
startCloudUIUpdateCheck), so a slow download holds up nothing that starts after it. The script runs with no time limit, since it gives up on a download that stops moving, and only the end of its output is kept for the log.When
CloudUIis missing or holds onlyversionandtag, the boot check runs the script with--force, since thatversionstill names the release the script would otherwise find installed.The rebuild route (
/flux/rebuildui) runs the script with--if-idle --forcethroughrebuildIfIdle: it installs the release whateverCloudUI/versionholds, so it repairs a damaged UI, and while another update is in progress, in FluxOS or in another process, it answers at once that one is in progress rather than holding the request behind it. The boot check and the watchdog wait their turn.The installed release tag
The script writes the release tag to
tagbesideversionin the build it installs, so the tag switches with the build.versionstill holds the release asset's sha256, which the watchdog and FluxOS compare with the release./flux/inforeportscloudUI: { tag, sha256 }, eachnullwhere the script has not written it.cloudUIExiststreats aCloudUIholding onlyversionandtagas empty.The watchdog
The watchdog runs this script (RunOnFlux/fluxnode-watchdog#54) in the background, one run at a time, and stops a run it has given up on with SIGTERM, which this script answers by removing its files.
Tests
tests/unit/updateCloudUiScript.test.jsruns the real script against a local server standing in for the GitHub API, in a throwaway project root (Linux only): fresh install, flat archive, folder → symlink with and without--exchange, symlink → symlink with and without--exchange, an installed release left alone with nothing downloaded, its reinstall with--forceand with--if-idle --force, a danglingCloudUIsymlink, a symlink outside the store; thetagandversionfiles of the installed build; every failure path (release fetch, missing asset/URL/digest, checksum mismatch, archive that does not unpack, failure with a folder still in place); a download and a release fetch that stop moving; a slow download that keeps moving; no API URL; noflock; SIGTERM mid-download, once, twice at once, and repeatedly until the run exits; SIGTERM or SIGPIPE arriving as the cleanup starts; a stop during a failed run's cleanup; a write and a stop after the output's reader has gone; SIGKILL mid-download and the next run's cleanup; leftovers of every kind; a run killed between the two fallback renames; an orphaned download not holding the lock; two concurrent runs, the second finding the first's release installed;--if-idleexiting 75 at once against a held lock and installing when idle; an unknown option. The signal cases are produced at the point they test (aBASH_ENVDEBUGtrap, areadlinkonPATH), so they do not depend on timing.cloudUIUpdateService.test.jscovers the background start, the absent time limit, a script ended by a signal, the bounded output, reading the tag file, the boot check forcing its install over aCloudUIholding onlyversionandtag, andrebuildIfIdle: its options, itsinstalled,failedandbusyanswers,busywithout a run while one is in flight, and an update joining a rebuild in flight;fluxService.test.jscovers thecloudUIfield and the rebuild route's three answers; itsgetFluxInfotests stub Docker and MongoDB, and its chain streaming preparation tests stub the app networks, so they pass or fail on the code under test alone. Harness suite 2803 sends its registration once the shaped node holds the policy, which the node needs before it resolves a repotag.Run on Ubuntu 22.04 (bash 5.1, coreutils 8.32), Debian bookworm (bash 5.2, coreutils 9.1), Ubuntu 25.04 (bash 5.2, coreutils 9.5, where the
--exchangecase runs) and Ubuntu 26.04 (bash 5.3). Each branch was broken separately and each turned the suite red; the three parts of the signal handling were each broken on bash 5.1, 5.2 and 5.3.Also run on an ArcaneOS node (systemd, watchdog) and a legacy node (pm2, FluxOS's own update): install over a real
CloudUIfolder by both paths, slow and stalled downloads, FluxOS answering while its boot download ran past five minutes, the released watchdog and FluxOS updating at once, and systemd and pm2 stopping a run mid-download, each leaving only the installed build.--if-idle,--forceand the installed-release check have run in the unit tests only.Unit (chud,
tests/images/run-unit.sh):fluxService,cloudUIUpdateServiceandupdateCloudUiScript: 317 passing, 1 pending, 0 failing.--if-idlemade to wait, the installed-release check removed, and the boot check's--forceremoved, each turn the new tests red.Harness gate (tester,
MAXN=6) at112c9271c7, this branch ondevelopment54cd524684: 324 of 325 suites passed. 2803 sent its registration 2 ms before the shaped node adopted the policy; with the suite's fix it passes alone on chud (4 of 4). The branch was then rebased ontodevelopmentf17f802717, which adds #1918 (networkStateManager.jsand its test, no file of this PR); every commit applies unchanged.🤖 Generated with Claude Code