Repository navigation
feat(init.sh): progress, failure handling and safe uploads for onboot commands - #199
Merged
Merged
Conversation
Onboot commands (linbo-remote -p) and linbo_autoinitcache passed their output line by line to print_status. The progress bars of qemu-img, rsync and pv redraw their line with \r and buildtorrent with \b, so "while read" held them back until the next newline: the splash showed e.g. the compression or upload message for minutes without any progress, and the zero filling of pv, drawn on stderr, not at all. run_with_status() now shows the stdout of these commands: in the splash every redraw becomes a status line of its own (tr '\r\b' '\n\n', blank pieces dropped), on the console the output goes as is to /dev/console, which draws the bars in place. stdout no longer goes to init.log in the console mode either, so the log gets no progress lines; stderr is left alone and keeps error messages in the log. linbo_create_image shows the progress of pv on stdout like the other steps, dd's own messages stay on stderr. Covered by tests/shell/test_init.sh. Signed-off-by: [email protected] Assisted-by: Claude
init.sh ignored the exit status of the onboot commands: a failed command was not logged, its messages on stdout were only shown in the splash, and the remaining commands still ran, e.g. the upload of an image whose creation had just failed. run_with_status() now keeps the stdout of the command in /tmp/run_with_status.out and returns the exit status of the command (pipefail in its subshell only). If an onboot command fails, init.sh logs it with its rc and the last ten lines of its stdout, every progress bar reduced to its last state by last_output_lines(), and skips the remaining onboot commands like linbo-remote -c does. linbo_autoinitcache is not checked, its exit status is 1 whenever there is nothing to do. Signed-off-by: [email protected] Assisted-by: Claude
linbo_upload only checked that the image file exists. After an aborted creation the incomplete qcow2 stayed in the cache and could be uploaded, replacing the good image on the server. linbo_upload now uploads a qcow2/qdiff image only if its info file exists and its imagesize is the actual size of the image. A completely created or downloaded image always has a matching info file, an aborted creation has the info file of the former version or, under a new name, none at all. The .complete marker cannot be used: since aria2c (#152) only linbo_create_image sets it, downloaded images do not have it. linbo_create_image removes the incomplete image when the compression fails. Covered by tests/shell/test_linbo_upload.sh. Signed-off-by: [email protected] Assisted-by: Claude
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Onboot commands (
linbo-remote -p) during the splash:9ab96b4):init.shpassed the output line by line toplymouth --update. qemu-img, rsync and pv redraw their progress with\r, buildtorrent with\b, so nothing was shown until a step ended; pv's zero filling (stderr) never reached the splash.run_with_status()turns every redraw into a status line (tr '\r\b' '\n\n', busybox tr is unbuffered); on the console the output is shown as is. stdout no longer goes toinit.log(no progress lines in the log), stderr still does.linbo_create_imageshows pv's progress on stdout.a2be6c2): the exit status was ignored. Now a failed command is logged with its rc and the last ten lines of its stdout (progress bars reduced to their last state), and the remaining onboot commands are skipped like withlinbo-remote -c, e.g. no upload after a failed image creation.dea35d6):linbo_uploadonly checked that the image exists. Now a qcow2/qdiff is only uploaded ifimagesizein its info file matches the file size (complete creation or download);linbo_create_imageremoves the incomplete image when the compression fails. The.completemarker cannot be used: since aria2c (replace ctorrent with aria2c #152) onlylinbo_create_imagesets it.Follow-up to #133 / #198.
Test plan
test_init.sh9,test_linbo_upload.sh5)init.shon multi-1 withupload_image:2::zzbad,rebootand a dummy image without info file: upload refused as incomplete, failure + last output logged,rebootskipped🤖 Generated with Claude Code