Skip to content

Commit fee527a

Browse files
committed
fix(extensions/netboot): always clean up remote rootfs archive on tar failure
The remote shell ran with `set -e`, so a tar failure (disk full on the NFS export, archive corruption, etc.) exited the shell before the `rm -f` and left a 200-800 MB rootfs archive in /tmp. Repeated failed deploys accumulate. Restructure to: mkdir && tar; capture rc; rm -f unconditionally; exit with the captured rc so Armbian's set -e still aborts on the real failure. Reported by coderabbitai (#9656 review, line 438). Assisted-by: Claude:claude-opus-4.7
1 parent 7bcded6 commit fee527a

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

extensions/netboot/netboot-deploy.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,16 @@ function netboot_artifacts_ready__deploy_to_remote_server() (
432432
# for SELinux contexts, and --numeric-owner so user/group resolution
433433
# uses the archive's numeric IDs (the target's /etc/passwd is what
434434
# matters at boot, not the deploy host's).
435+
# Cleanup of the staged archive must run regardless of mkdir/tar
436+
# outcome — without that, a `set -e` shell on the remote exits on
437+
# tar failure and leaves the 200–800 MB rootfs archive under /tmp.
438+
# `&&` keeps mkdir→tar short-circuit; capture the rc, run rm
439+
# unconditionally, propagate the original rc so Armbian's set -e
440+
# still aborts on the real failure.
435441
run_host_command_logged_raw ssh "${ssh_opts[@]}" "${NETBOOT_DEPLOY_SSH}" \
436-
"set -e; ${sudo_prefix}mkdir -p ${q_nfs_path}; \
437-
${sudo_prefix}tar -xp --numeric-owner --xattrs --xattrs-include='*' --acls --selinux -f ${q_remote_archive} -C ${q_nfs_path}; \
438-
rm -f ${q_remote_archive}"
442+
"${sudo_prefix}mkdir -p ${q_nfs_path} \
443+
&& ${sudo_prefix}tar -xp --numeric-owner --xattrs --xattrs-include='*' --acls --selinux -f ${q_remote_archive} -C ${q_nfs_path}; \
444+
ret=\$?; rm -f ${q_remote_archive}; exit \${ret}"
439445
else
440446
display_alert "${EXTENSION}: no archive" \
441447
"ROOTFS_EXPORT_DIR path — builder writes directly, skip" "info"

0 commit comments

Comments
 (0)