From d5a8987d44014c1aa78638646ec6c665ee4e9b8c Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Wed, 18 Nov 2026 09:10:27 -0800 Subject: [PATCH 1/2] docs(lab): record template 901 rebuilt; smoke-test for a leftover packer user 901 was rebuilt with no-initramfs-network.sh and packer-smoke.sh 901 passed, no DHCP before switch-root included. The rebuild's userdel printed a busy warning that -f goes past, but `|| true` would hide a failed delete, so the smoke test now fails a Linux clone that still has a packer user. Refs #1569 Co-Authored-By: Claude Opus 5.5 --- docs/changelog.md | 17 +++++++++++++++++ docs/runbooks/build-the-lab-templates.md | 5 +++-- scripts/packer-smoke.sh | 19 +++++++++++++++++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index d42394c6..3f708e6b 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -64,6 +64,23 @@ docstring gives: it is a record, not a claim about now. A smart plug or an infrared LED would be a purchase and an ADR of its own (`build-heimdall.md` §8). +- **Template `901` is rebuilt without networking in its initramfs, and its + clones take no lease while they boot.** This completes "`eden` no longer + asks for an address while it boots", below, which said `901` had not been + rebuilt. `packer build -force -only='ubuntu.*'` on `phoenix` took 24 min + 31 s. The upgrade's autoremove took out the installer's `7.0.0-30` kernel + first, so `no-initramfs-network.sh` rebuilt one image, `7.0.0-43`, and its + `lsinitrd` check passed; the `dracut[E]` line for `dyn-netconf` came as + expected. `scripts/packer-smoke.sh 901` then passed every check, `no DHCP + before switch-root` among them. The clone's `.103` came from its own + cloud-init DHCP after the switch, which the smoke test asks for. + - **The build user:** the last provisioner's `userdel -f -r packer` printed + "user packer is currently used by process 1392". With `-f` that is a + warning, and the mail-spool line after it shows the delete went on, but + `|| true` would have hidden a failure and nothing checked. The smoke test + now fails a Linux clone that still has a `packer` user. + - **Not changed:** guests cloned from the old `901` keep their old image. + `eden`, the clone today's lease check found, already has its §2 step. - **`eden` no longer asks for an address while it boots, and template `901` stops making guests that do.** `eden` was off when "Every 26.04 lab guest asked the lab's DHCP server for an address while it booted", below, was diff --git a/docs/runbooks/build-the-lab-templates.md b/docs/runbooks/build-the-lab-templates.md index 67f67925..8278ec24 100644 --- a/docs/runbooks/build-the-lab-templates.md +++ b/docs/runbooks/build-the-lab-templates.md @@ -672,8 +672,9 @@ scripts/packer-smoke.sh 910 Each run makes a full clone at VMID 999. For Linux, it gives the clone user `smoke`, `phoenix`'s key and DHCP through cloud-init, boots it, and waits for -the agent to report an address. It then checks the hostname and SSHes in. -Where the clone booted through a systemd initramfs, it checks the journal +the agent to report an address. It then checks the hostname, SSHes in, and +checks that the build's `packer` user is gone: the build deletes it with +`|| true`, so a failed delete does not fail the build. Where the clone booted through a systemd initramfs, it checks the journal shows no DHCP before switch-root; a clone of a `901` built before `no-initramfs-network.sh` fails there. Finally it destroys the clone. diff --git a/scripts/packer-smoke.sh b/scripts/packer-smoke.sh index cb7b4272..0e7f8924 100755 --- a/scripts/packer-smoke.sh +++ b/scripts/packer-smoke.sh @@ -14,8 +14,9 @@ # Linux the clone takes its name, user and key from the Proxmox cloud-init # drive: the agent reports an address, get-host-name returns the name # given here, and phoenix's key opens an SSH session that prints it. -# Where the clone booted through a systemd initramfs, its journal -# shows no DHCP before switch-root. +# No `packer` build user is left in it. Where the clone booted +# through a systemd initramfs, its journal shows no DHCP before +# switch-root. # Windows the generalised image finishes OOBE unattended and the guest agent # comes up with an address. The agent is disabled in the template # and started by SetupComplete.cmd as its last act, so an address @@ -205,6 +206,20 @@ if [[ "${ostype}" == l26 ]]; then got="$(ssh_hostname smoke)" || die "smoke@${addr} admitted no SSH login in three minutes" [[ "${got}" == "${NAME}" ]] || die "ssh smoke@${addr} printed ${got}, expected ${NAME}" ok "phoenix's key opens smoke@${addr}" + # The templates that build as `packer` delete that user last, with + # `userdel -f -r packer || true`. The `|| true` keeps a failed delete from + # failing the build, so a template that still has the user is caught here. + # 901's rebuild of 2026-11-18 printed "user packer is currently used by + # process", a warning -f goes past. getent exits 2 for no such user; a + # template whose build user has another name passes trivially. + leftover="$(ssh -i "${SSH_KEY}" -o BatchMode=yes -o StrictHostKeyChecking=no \ + -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR "smoke@${addr}" \ + 'getent passwd packer >/dev/null; echo $?' 2>/dev/null | tr -d '\r')" + case "${leftover}" in + 2) ok "no packer build user left behind" ;; + 0) die "the build user packer is still in the clone: the template's userdel failed" ;; + *) die "could not check for the packer build user (${leftover:-no answer})" ;; + esac # A clone must not ask for an address before switch-root. Ubuntu's dracut # initramfs did, on every clone of 901, until no-initramfs-network.sh: eden # leased from the lab pool at each boot (packer/ubuntu/no-initramfs-network.sh). From 4ffdb0d0b03c590f9bbc7c12f48445418e850d97 Mon Sep 17 00:00:00 2001 From: Gerrrt Date: Wed, 18 Nov 2026 10:03:33 -0800 Subject: [PATCH 2/2] fix(smoke): say why when an SSH check fails, not stop silently MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Under set -e a failed x="$(ssh … 2>/dev/null)" ended the script with nothing printed. The packer-user, early-DHCP and Panther checks now go through ssh_run, which prints ssh's stderr and the exit status before it dies. Refs #1569 Co-Authored-By: Claude Opus 5.5 --- scripts/packer-smoke.sh | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/scripts/packer-smoke.sh b/scripts/packer-smoke.sh index 0e7f8924..020c1354 100755 --- a/scripts/packer-smoke.sh +++ b/scripts/packer-smoke.sh @@ -199,6 +199,27 @@ ssh_hostname() { return 1 } +# One command on the clone, once the login above has worked; prints its output. +# Under `set -e` a bare `x="$(ssh …)"` that fails ends the script with nothing +# said, so a failure here prints ssh's own stderr and the exit status first. +# Called as x="$(ssh_run …)", die leaves only the subshell, and the failed +# assignment then stops the script with the message already on screen. Every +# command sent through here exits 0 on the guest whatever it finds. +ssh_run() { + local user="$1" cmd="$2" out err rc=0 + err="$(mktemp)" + out="$(ssh -i "${SSH_KEY}" -o BatchMode=yes -o StrictHostKeyChecking=no \ + -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR \ + -o ConnectTimeout="${SSH_CONNECT_TIMEOUT}" \ + "${user}@${addr}" "${cmd}" 2>"${err}")" || rc=$? + if ((rc != 0)); then + cat "${err}" >&2; rm -f "${err}" + die "ssh ${user}@${addr} exited ${rc} running a check" + fi + rm -f "${err}" + printf '%s' "${out}" | tr -d '\r' +} + host="$(api GET "/nodes/${NODE}/qemu/${CLONE}/agent/get-host-name" | jq -r '.data.result."host-name"')" if [[ "${ostype}" == l26 ]]; then [[ "${host}" == "${NAME}" ]] || die "hostname is ${host}, expected ${NAME}" @@ -212,9 +233,7 @@ if [[ "${ostype}" == l26 ]]; then # 901's rebuild of 2026-11-18 printed "user packer is currently used by # process", a warning -f goes past. getent exits 2 for no such user; a # template whose build user has another name passes trivially. - leftover="$(ssh -i "${SSH_KEY}" -o BatchMode=yes -o StrictHostKeyChecking=no \ - -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR "smoke@${addr}" \ - 'getent passwd packer >/dev/null; echo $?' 2>/dev/null | tr -d '\r')" + leftover="$(ssh_run smoke 'getent passwd packer >/dev/null; echo $?')" case "${leftover}" in 2) ok "no packer build user left behind" ;; 0) die "the build user packer is still in the clone: the template's userdel failed" ;; @@ -225,13 +244,12 @@ if [[ "${ostype}" == l26 ]]; then # leased from the lab pool at each boot (packer/ubuntu/no-initramfs-network.sh). # Only where the boot went through a systemd initramfs, whose journal marks # the switch; a template without one has nothing here to check. - early="$(ssh -i "${SSH_KEY}" -o BatchMode=yes -o StrictHostKeyChecking=no \ - -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR "smoke@${addr}" \ + # shellcheck disable=SC2016 # the guest's shell expands these, not this one + early="$(ssh_run smoke \ 'command -v journalctl >/dev/null || { echo none; exit 0; } j="$(sudo -n journalctl -b -o cat 2>/dev/null)" || { echo unreadable; exit 0; } printf "%s\n" "$j" | grep -q "Switching root" || { echo none; exit 0; } - printf "%s\n" "$j" | awk "/Switching root/{exit} {print}" | grep -cE "DHCPv4 address|zzzz-dracut-default" || true' \ - 2>/dev/null | tr -d '\r')" + printf "%s\n" "$j" | awk "/Switching root/{exit} {print}" | grep -cE "DHCPv4 address|zzzz-dracut-default" || true')" case "${early}" in 0) ok "no DHCP before switch-root" ;; none) ok "no systemd initramfs on this family, so no early DHCP to check" ;; @@ -253,7 +271,7 @@ else # refuses to start the agent if either survives, so reaching here already means # they are gone; assert it over SSH anyway, so a scrub regression cannot ship a # usable template silently. - leak="$(ssh -i "${SSH_KEY}" -o BatchMode=yes -o StrictHostKeyChecking=no "Administrator@${addr}" 'powershell -NoProfile -Command "if ((Test-Path C:\Windows\Panther\unattend.xml) -or (Test-Path C:\Windows\Panther\unattend-original.xml)) { Write-Output LEAK }"' 2>/dev/null | tr -d '\r')" + leak="$(ssh_run Administrator 'powershell -NoProfile -Command "if ((Test-Path C:\Windows\Panther\unattend.xml) -or (Test-Path C:\Windows\Panther\unattend-original.xml)) { Write-Output LEAK }"')" [[ -z "${leak}" ]] || die "Panther answer files still present on ${addr} (#1099): the plaintext build password is readable by Users" ok "Panther answer files scrubbed (#1099)" fi