Skip to content

Commit 8b2b065

Browse files
Marketenclaude
andcommitted
Fix false "Corrupted" images in the first-boot test
The image integrity test read image IDs from column 3 of `docker images`. Newer Docker versions changed the default table (IMAGE, ID, DISK USAGE, ...), so column 3 is now the image size: the test ran `docker save 171MB` and reported every image as corrupted on fresh installs, then still said "Test completed successfully". - List and check images with explicit `--format` strings, by repo:tag. - Fix the missing `echo -e` that printed raw escape codes. - Only say "completed successfully" when no image failed. - Log the test to logs/dappnode_test_install.log; it runs on its own console and left no record. - Make the ISO E2E fail when that log reports corrupted images or no success, and fix a `! grep` check that could never fail under set -e. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e7030fd commit 8b2b065

2 files changed

Lines changed: 41 additions & 6 deletions

File tree

‎scripts/dappnode_test_install.sh‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
HOME=${HOME:-/home/dappnode}
44
DAPPNODE_DIR="/usr/src/dappnode"
5+
LOG_FILE="${DAPPNODE_DIR}/logs/dappnode_test_install.log"
6+
7+
# This runs on its own console, so also keep a log for support and the E2E tests.
8+
mkdir -p "$(dirname "${LOG_FILE}")"
9+
exec > >(tee -a "${LOG_FILE}") 2>&1
510

611
error_exit() {
712
echo -e "\e[31m Error on installation!!! \n \e[0m"
@@ -51,16 +56,27 @@ for comp in "${components[@]}"; do
5156
fi
5257
done
5358

59+
# Use explicit formats: the default `docker images` columns differ between
60+
# Docker versions, and newer ones put the image size where the ID used to be.
5461
echo -e "\e[32m docker image versions:\e[0m"
55-
docker images | grep dappnode | awk '{print $1, $2}'
62+
docker images --format '{{.Repository}}:{{.Tag}} {{.ID}}' | grep dappnode
5663

5764
echo -e "\e[32m doing docker image integrity test...\e[0m"
58-
imgs=$(docker images | grep dappnode | awk '{print $3}')
65+
imgs=$(docker images --format '{{.Repository}}:{{.Tag}}' | grep dappnode)
5966

67+
corrupted_imgs=()
6068
for img in $imgs; do
61-
# shellcheck disable=SC2028
62-
docker save "$img" >/dev/null && echo -ne "\e[32mImage $img OK\n\e[0m" || echo "\e[31mImage $img Corrupted!\n\e[0m"
69+
if docker save "$img" >/dev/null; then
70+
echo -e "\e[32mImage $img OK\e[0m"
71+
else
72+
echo -e "\e[31mImage $img Corrupted!\e[0m"
73+
corrupted_imgs+=("$img")
74+
fi
6375
done
6476

6577
rm -f /usr/src/dappnode/.firstboot
66-
read -r -p "Test completed successfully. Press enter to continue"
78+
if [ "${#corrupted_imgs[@]}" -gt 0 ]; then
79+
read -r -p "Test completed with corrupted images: ${corrupted_imgs[*]}. Press enter to continue"
80+
else
81+
read -r -p "Test completed successfully. Press enter to continue"
82+
fi

‎test/e2e_iso_install.sh‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,26 @@ test -x /usr/src/dappnode/scripts/dappnode_install.sh
485485
test -s /usr/src/dappnode/logs/iso_install.log
486486
test -s /usr/src/dappnode/logs/dappnode_install.log
487487
test ! -e /usr/src/dappnode/.firstboot
488-
! grep -Fq '/usr/src/dappnode/scripts/dappnode_install.sh' /etc/rc.local
488+
# `! cmd` never trips `set -e`, so negative checks need an explicit exit.
489+
if grep -Fq '/usr/src/dappnode/scripts/dappnode_install.sh' /etc/rc.local; then
490+
echo "[ERROR] rc.local still runs the DAppNode installer"
491+
exit 1
492+
fi
493+
494+
# The first-boot self-test runs on its own console; its log is the only record.
495+
first_boot_test_log=/usr/src/dappnode/logs/dappnode_test_install.log
496+
test -s "${first_boot_test_log}"
497+
if grep -Fq 'Corrupted' "${first_boot_test_log}"; then
498+
echo "[ERROR] The first-boot test reported corrupted images:"
499+
grep -F 'Image ' "${first_boot_test_log}"
500+
exit 1
501+
fi
502+
if ! grep -Fq 'Test completed successfully' "${first_boot_test_log}"; then
503+
echo "[ERROR] The first-boot test did not report success:"
504+
tail -n 30 "${first_boot_test_log}"
505+
exit 1
506+
fi
507+
grep -F 'Image ' "${first_boot_test_log}"
489508
docker --version
490509
docker compose version
491510
docker info >/dev/null

0 commit comments

Comments
 (0)