fix: the clone identity reset could never reboot, so it never took effect #30

Merged
dan-claude-bot merged 1 commit from fix/reset-identity-restart into main 2026-07-14 00:05:48 +00:00
dan-claude-bot commented 2026-07-14 00:04:24 +00:00 (Migrated from github.com)

My fix in #27 was right about the cause and wrong about the mechanism. Run 7:

FAIL  clone FAILED — claudebox: giving the clone its own identity (machine-id, DHCP lease)...
      Error: Failed shutting down instance, status is "Running": context deadline exceeded

systemd needs a valid /etc/machine-id to shut down cleanly. #27 truncated it and then called incus restart — so the graceful stop hung, Incus timed out, and the reboot never happened. The new machine-id only takes effect at boot, so the clone kept its source's identity: the exact bug the reset exists to prevent.

And it cascaded

The duplicate address didn't just break cloning — it broke the box. Run 7's audit shows box cannot reach the internet (two boxes fighting over 10.87.0.215), and phase D then reported mac+ipv4 filtering BROKE the box's networking — design veto against #16. That verdict is false; the box was already broken. (Guarded separately in the drill.)

The fix

Write a fresh valid id rather than emptying the file:

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

systemd-machine-id-setup derives it from the DMI product UUID, which Incus makes unique per instance — so the clone gets an identity that is genuinely its own, not a random one. Then restart with a real timeout and a forced fallback:

incus restart --timeout 60 "$i" >/dev/null 2>&1 || incus restart -f "$i"

A clone that keeps its source's DHCP lease is worse than an unclean stop of a box that booted thirty seconds ago.

Verify

claudebox new --name a --from <src>/<snap>
claudebox new --name b --from <src>/<snap>
incus list                                            # a and b: DIFFERENT 10.87.x
for x in a b; do incus exec $x -- cat /etc/machine-id; done   # must differ

🤖 Generated with Claude Code

My fix in #27 was right about the cause and wrong about the mechanism. Run 7: ``` FAIL clone FAILED — claudebox: giving the clone its own identity (machine-id, DHCP lease)... Error: Failed shutting down instance, status is "Running": context deadline exceeded ``` **`systemd` needs a valid `/etc/machine-id` to shut down cleanly.** #27 truncated it and then called `incus restart` — so the graceful stop hung, Incus timed out, and **the reboot never happened**. The new machine-id only takes effect at boot, so the clone kept its source's identity: the exact bug the reset exists to prevent. ## And it cascaded The duplicate address didn't just break cloning — it broke the box. Run 7's audit shows `box cannot reach the internet` (two boxes fighting over `10.87.0.215`), and phase D then reported **`mac+ipv4 filtering BROKE the box's networking — design veto`** against #16. That verdict is false; the box was already broken. (Guarded separately in the drill.) ## The fix Write a fresh **valid** id rather than emptying the file: ```sh 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 ``` `systemd-machine-id-setup` derives it from the **DMI product UUID**, which Incus makes unique per instance — so the clone gets an identity that is genuinely its own, not a random one. Then restart with a real timeout and a forced fallback: ```sh incus restart --timeout 60 "$i" >/dev/null 2>&1 || incus restart -f "$i" ``` A clone that keeps its source's DHCP lease is worse than an unclean stop of a box that booted thirty seconds ago. ## Verify ```sh claudebox new --name a --from <src>/<snap> claudebox new --name b --from <src>/<snap> incus list # a and b: DIFFERENT 10.87.x for x in a b; do incus exec $x -- cat /etc/machine-id; done # must differ ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: heavy-duty/box#30
No description provided.