fix: the clone identity reset could never reboot, so it never took effect
The reset truncated /etc/machine-id and called 'incus restart'. But
systemd needs a VALID machine-id to shut down cleanly — so the graceful
stop hung, incus timed out ("Failed shutting down instance, status is
Running: context deadline exceeded"), and the reboot never happened. The
clone kept its source's machine-id, hence its DUID, hence its DHCP
lease: two boxes on one address, which is the exact bug the reset exists
to prevent. Worse, the duplicate address then broke the box's networking
outright ("box cannot reach the internet"), and poisoned the isolation
run downstream.
Write a fresh VALID id with systemd-machine-id-setup instead of emptying
the file — in a VM it derives from the DMI product UUID, which Incus
makes unique per instance. Then restart with a real timeout and a forced
fallback: a clone that keeps its source's lease is worse than an unclean
stop of a box that booted thirty seconds ago.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
b93b90fa0d
commit
4e2c6c9caf
1 changed files with 12 additions and 3 deletions
|
|
@ -417,12 +417,21 @@ wait_agent() {
|
|||
reset_identity() {
|
||||
local i="$1"
|
||||
echo "claudebox: giving the clone its own identity (machine-id, DHCP lease)..."
|
||||
# Do NOT truncate machine-id and reboot: systemd needs a valid one to shut
|
||||
# down cleanly, so the graceful stop hangs and the reboot never happens —
|
||||
# leaving the clone on its source's identity, which is the bug we are here to
|
||||
# fix. 'systemd-machine-id-setup' writes a fresh VALID id instead; in a VM it
|
||||
# derives from the DMI product UUID, which Incus makes unique per instance.
|
||||
incus exec "$i" -- sh -c '
|
||||
: >/etc/machine-id
|
||||
rm -f /var/lib/dbus/machine-id
|
||||
rm -f /etc/machine-id /var/lib/dbus/machine-id
|
||||
systemd-machine-id-setup >/dev/null 2>&1 || dbus-uuidgen > /etc/machine-id
|
||||
ln -sf /etc/machine-id /var/lib/dbus/machine-id
|
||||
test -s /etc/machine-id
|
||||
' || die "could not reset the clone's machine-id"
|
||||
incus restart "$i"
|
||||
# The new id only takes effect at boot. Ask nicely, then insist — a clone that
|
||||
# keeps its source's DHCP lease is worse than an unclean stop of a box that
|
||||
# booted 30 seconds ago.
|
||||
incus restart --timeout 60 "$i" >/dev/null 2>&1 || incus restart -f "$i"
|
||||
wait_agent "$i"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue