Skip to content

Commit cc60a22

Browse files
committed
common: Print debugging info along the backtrace
Recently we had some problems with read-only filesystems, that pop up in different places. It may be easier to catch if the debugging info is printed in an error case instead of just one specific location.
1 parent e3f817a commit cc60a22

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

build_library/sysext_prod_builder

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,7 @@ create_prod_sysext() {
6767
sudo mv "${workdir}/sysext-build/${name}.raw" "${workdir}/sysext-build/${name}_pkginfo.raw" \
6868
"${workdir}/sysext-build/${name}"_*.txt "${output_dir}"
6969

70-
sudo mkdir -p "${install_root}"/usr/share/flatcar/sysext || {
71-
echo "DEBUG OUTPUT:"
72-
mount
73-
df -h
74-
sudo dmesg
75-
echo "END DEBUG OUTPUT"
76-
exit 1
77-
}
70+
sudo mkdir -p "${install_root}"/usr/share/flatcar/sysext
7871
sudo install -m 0644 -D "${output_dir}/${name}.raw" "${install_root}"/usr/share/flatcar/sysext/
7972

8073
sudo mkdir -p "${install_root}"/etc/extensions/

common.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,40 @@ die_notrace() {
164164
for line in "$@"; do
165165
error "${DIE_PREFIX}${line}"
166166
done
167+
if [[ ! -e "${SCRIPTS_DIR}/NO_DEBUG_OUTPUT_DELETE_ME" ]]; then
168+
error "${DIE_PREFIX}!!!!!!!!!!!!!!!!!!!!!!!!!"
169+
error "${DIE_PREFIX}!! BEGIN DEBUG OUTPUT: !!"
170+
error "${DIE_PREFIX}!!!!!!!!!!!!!!!!!!!!!!!!!"
171+
error
172+
error "${DIE_PREFIX}== MOUNT =="
173+
error "${DIE_PREFIX}==========="
174+
error_command_output "${DIE_PREFIX}" mount
175+
error
176+
error "${DIE_PREFIX}== DF =="
177+
error "${DIE_PREFIX}========"
178+
error_command_output "${DIE_PREFIX}" df -h
179+
error
180+
error "${DIE_PREFIX}== DMESG =="
181+
error "${DIE_PREFIX}==========="
182+
error_command_output "${DIE_PREFIX}" sudo dmesg
183+
error
184+
error "${DIE_PREFIX}!!!!!!!!!!!!!!!!!!!!!!!"
185+
error "${DIE_PREFIX}!! END DEBUG OUTPUT: !!"
186+
error "${DIE_PREFIX}!!!!!!!!!!!!!!!!!!!!!!!"
187+
touch "${SCRIPTS_DIR}/NO_DEBUG_OUTPUT_DELETE_ME"
188+
fi
167189
exit 1
168190
}
169191

192+
error_command_output() {
193+
local prefix=${1}; shift
194+
# rest are a command to execute
195+
local REPLY
196+
while read -r; do
197+
error "${prefix}${REPLY}"
198+
done < <("${@}" 2>&1)
199+
}
200+
170201
# Simple version comparison routine
171202
# Note: not a true semver comparison and build revisions are ignored
172203
cmp_ver() {
@@ -296,6 +327,8 @@ BUILD_LIBRARY_DIR="${SCRIPTS_DIR}/build_library"
296327
REPO_CACHE_DIR="${REPO_ROOT}/.cache"
297328
REPO_MANIFESTS_DIR="${REPO_ROOT}/.repo/manifests"
298329

330+
rm -f "${SCRIPTS_DIR}/NO_DEBUG_OUTPUT_DELETE_ME" || :
331+
299332
# Source FLATCAR_VERSION_ID from manifest.
300333
if [[ -f "${REPO_MANIFESTS_DIR}/version.txt" ]]; then
301334
# The build id may be provided externally by the build system.

0 commit comments

Comments
 (0)