Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions docs/runbooks/build-the-lab-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
47 changes: 40 additions & 7 deletions scripts/packer-smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -198,25 +199,57 @@ 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}"
ok "hostname ${host}"
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_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" ;;
*) 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).
# 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" ;;
Expand All @@ -238,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
Expand Down
Loading