Skip to content

Commit 3eede83

Browse files
committed
fix install log for incus
1 parent 5ba866d commit 3eede83

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

incus/backend.func

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,8 +1005,12 @@ INNEREOF" >>"${LOGFILE:-$INCUS_BUILD_LOG}" 2>&1 || { msg_error "Failed to push f
10051005
# reported as a success against an empty container.
10061006
set +Eeuo pipefail
10071007
trap - ERR
1008+
# The trailing touch is a completion sentinel: all 552 install scripts run to
1009+
# cleanup_lxc/customize and none exits early, so the marker appears if and
1010+
# only if the script reached its end.
10081011
incus exec "${CT_NAME}" -- bash -c "${_run_env}
1009-
${_install_script}" 2>&1 | tee -a "${LOGFILE:-$INCUS_BUILD_LOG}" || lxc_exit=$?
1012+
${_install_script}
1013+
touch /root/.install-${SESSION_ID}.done" 2>&1 | tee -a "${LOGFILE:-$INCUS_BUILD_LOG}" || lxc_exit=$?
10101014
set -Eeuo pipefail
10111015
declare -f error_handler &>/dev/null && trap 'error_handler' ERR || true
10121016

@@ -1018,6 +1022,20 @@ ${_install_script}" 2>&1 | tee -a "${LOGFILE:-$INCUS_BUILD_LOG}" || lxc_exit=$?
10181022
fi
10191023
fi
10201024
[[ "$install_exit_code" -eq 0 && "$lxc_exit" -ne 0 ]] && install_exit_code=$lxc_exit
1025+
1026+
# A shell killed mid-run - by the kernel, or by the terminal fault the pty
1027+
# experiment caused - never reaches its ERR trap, so no .failed flag is
1028+
# written and `incus exec` still reports 0. Without the sentinel that counted
1029+
# as success, and the operator got a URL pointing at an empty container.
1030+
if [[ "$install_exit_code" -eq 0 && -n "${SESSION_ID:-}" ]]; then
1031+
if incus_ct_exec test -f "/root/.install-${SESSION_ID}.done" 2>/dev/null; then
1032+
incus_ct_exec rm -f "/root/.install-${SESSION_ID}.done" 2>/dev/null || true
1033+
else
1034+
msg_error "Install script stopped before it finished - nothing reported it"
1035+
msg_custom "ℹ️" "${YW}" "Output: incus exec ${CT_NAME} -- tail -50 /root/.install-${SESSION_ID}.log"
1036+
install_exit_code=1
1037+
fi
1038+
fi
10211039
INCUS_LAST_INSTALL_EXIT=$install_exit_code
10221040
}
10231041

0 commit comments

Comments
 (0)