update-cosmos: publish download and install progress for the on-screen updater - #308
update-cosmos: publish download and install progress for the on-screen updater#308kyleinoregon wants to merge 1 commit into
Conversation
Write the current state to /run/cosmos-update.status as a single "<state>|<percent>" line (downloading, flashing, rebooting, failed) so the on-screen UI can show what is happening instead of a static message. The file is written to a temporary name and renamed, so a reader never sees a partial line, and every write ends in "|| true" so status reporting can never fail the update itself. Download progress is the partial file size against the asset size from a HEAD request; if the size is unavailable the percentage stays at 0 and the download proceeds as before. curl and flash failures now report "failed" before exiting non-zero. URLs, flash, cleanup, reboot and exit codes are unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
If this gets merged, I will merge the Grumpyscreen change :-) |
450759d to
b5c46de
Compare
|
Trimmed this to just the update-cosmos script. The grumpyscreen side (pellcorp/grumpyscreen#287) now defaults to /run/cosmos-update.status, so no recipe change is needed here. |
|
I wonder if it might be nicer to change GrumpyScreen to parse stdout and if it sees special messages echoed from the script it shows them rather than a progress dialog, could just be a forever progress dialog like windows other UIs use where it swishes too and fro until the process finishes but you could be displaying progress textually instead. |
suchmememanyskill
left a comment
There was a problem hiding this comment.
I don't think this is the right way to go. Why do we need this precise update control/status messaging? Any of this won't work for mainsail/fluidd, and i'd prefer to have consistency across all ui's. I'm open to discussion after i'm back from holiday.
|
I agree with Sims that if we are to make more changes to the update system, I would like to see it done in a way to have consistency across UIs. I think extending moonrakers |
|
That makes sense to me, and it fixes more than the feedback problem. A cosmos updater in update_manager would replace both the check-for-updates prompt and the shell-command path: Mainsail and Fluidd would show the version badge and the live update log in their existing panel, the update would no longer block Klipper's command queue or run under the 500 s shell-command timeout, and the screen would follow whatever pellcorp decides for the update_manager interface. I've looked at the Moonraker side: it needs a small addition registering a cosmos updater type, which fits alongside the Moonraker patches cosmos already carries, and the existing update-cosmos script plugs in as the update step with its output streamed. If you're open to it I'll prototype that and test it here, and we can close this PR in favour of it. On the grumpyscreen side, if @pellcorp is open to it I'm happy to take a run at the update_manager client there too (status query, an Update button that calls machine.update.client, and the streamed log in a dialog) and send it as a PR for him to review. pellcorp/grumpyscreen#286 stays as the standalone fix for the screen freezing on the button press. |
|
The update manager in moonraker does not allow you to call a script, the moonraker update_script flag is used purely to parse for dependencies, I assume at some point it did run the script, last time I checked that is no longer the case. If we are talking about some mutations cosmos made to moonraker to support an update script, this is getting into territory I am less comfortable with. So I need more information |
So if the API for update client is stock moonraker and all the custom stuff for cosmos is behind that I am less concerned, but all that code must be gated inside the UPDATE flag because Simple AF does not use the Update button, that is all Cosmos. But I really don't want to force you guys to fork GrumpyScreen or maintain patches cos that makes things more complicated, so im willing to entertain this :-) |
|
Closing in favour of #313, which moves the update into Moonraker's update_manager as suggested here, so Mainsail, Fluidd and the screen all show the same thing. Thanks for the pointers. |
What
update-cosmosnow writes its state to/run/cosmos-update.statusas a single<state>|<percent>line, with state one ofdownloading,flashing,rebooting,failed, so a UI can show what is happening. The file is written to a temporary name and renamed, so a reader never sees a partial line, and every write ends in|| true, so status reporting can never fail the update itself.Download progress comes from the asset size (
curl -sILand the lastContent-Length; GitHub's release CDN answers HEAD with the real size on the final hop, 124226048 bytes for both the stable and nightly asset) againstwc -cof the partial file, sampled once a second whilecurlruns in the background. If the size is unavailable the percentage simply stays at 0 and the download proceeds as before. Acurlfailure or aflashfailure writesfailedbefore exiting non-zero.The consumer is pellcorp/grumpyscreen#287, which reads exactly this path by default, so no recipe change is needed on the cosmos side.
Behaviour is otherwise identical: same URLs, same
flash, same cleanup, samereboot, same exit codes.Tested
On a Centauri Carbon running 26.08.0 with a grumpyscreen build that reads the file: live percentage through the whole 124 MB download, "Installing" during the flash, then the reboot; the printer came back with its config untouched.
/runis tmpfs on this image and/bin/shis BusyBox ash with 64-bit arithmetic, sobytes * 100cannot overflow.