Skip to content

fix(os): guard the loop-partition race and the debug->release update trap - #827

Merged
VijitSingh97 merged 3 commits into
feat/phase2-bakery-imagefrom
fix/818-819-image-tooling
Aug 1, 2026
Merged

fix(os): guard the loop-partition race and the debug->release update trap#827
VijitSingh97 merged 3 commits into
feat/phase2-bakery-imagefrom
fix/818-819-image-tooling

Conversation

@VijitSingh97

Copy link
Copy Markdown
Collaborator

Two os-image tooling fixes.

losetup -P race (#818)

os/rauc/mkimage.sh ran mkfs.vfat on /dev/loopNp1 before udev published the node — the retry-clears failure seen cutting RC20 beside a running KVM battery. Now one guarded wait after losetup -P: udevadm settle plus a bounded poll (25 × 0.2 s) for both partition nodes, with a hard error if they never appear. tests/os/verify-image.sh opens the image the same way, so it gets the same wait (its first check counts partitions immediately).

Variant stamp + install guard (#819)

The SSH bake step defines the variant, so it stamps it:

  • /etc/pithead-variant (debug|release) written by os/rootfs/Containerfile — travels in the rootfs tarball into the image, every installed slot (pithead-install copies the running slot) and the bundle payload.
  • [meta.pithead] variant= in the bundle manifest, written by os/rauc/mkbundle.sh from the rootfs the bundle ships, so the metadata cannot drift from the payload.

Guard surface: a new pithead os-update BUNDLE [-y] subcommand. There is no pithead-owned install wrapper today — the only channels are the manual rauc install (doc M7) and the KVM harness. A RAUC pre-install handler would guard every channel but cannot ask a question (it runs daemon-side, no tty), and the requested behaviour is warn-and-confirm. So the wrapper is the smallest honest surface: it reads both stamps, and when the running system is debug and the bundle is not (release or unstamped — an old bundle without the stamp is shell-less too), it warns that the install removes the SSH channel driving it and requires y/N or --yes. Everything else installs unprompted. M7 now points at it; a bare rauc install still works and the docs say what skipping the guard costs.

verify-image asserts the stamp matches its mode: --test expects debug, release mode expects release (a debug image stamped release would defeat the guard).

Tests

  • tests/stack/run.sh: 19 new assertions — the confirmation gate matrix, stamp-file and rauc info JSON parsing (nesting-tolerant, garbage → unknown), and the command end to end with a stubbed rauc: refused non-interactively with no --yes, proceeds with it, release→release unprompted, rauc install provably not reached on refusal. Suite: 1900 passed, 0 failed.
  • tests/os/verify-image.sh: variant-stamp assertion in both modes (battery not run — bench-tier).
  • make lint and make test green (shellcheck, shfmt, docs voice, operator strings).

Bench should verify via a real A/B cycle: build a debug image + a release bundle, confirm rauc info shows the meta section on trixie's RAUC, confirm pithead os-update warns and that --yes installs; then a debug→debug update installs unprompted and verify-image passes in both modes.

Closes #818
Closes #819

🤖 Generated with Claude Code

VijitSingh97 and others added 2 commits August 1, 2026 15:39
…trap

Two image-tooling fixes, one surface each:

mkimage.sh raced losetup -P against udev publishing the partition nodes
— mkfs.vfat hit /dev/loopNp1 before it existed, likeliest exactly when
the release box is busiest. One guarded wait (udevadm settle + a bounded
poll for both nodes) before the first mkfs, mirrored in verify-image.sh
which opens the image the same way.

The build variant (debug = SSH baked, release = shell-less) is now
stamped where tooling can read it after the build: /etc/pithead-variant
in the rootfs — so every image, installed slot and running system
carries it — and [meta.pithead] variant= in the update bundle manifest,
read from the rootfs the bundle actually ships. `pithead os-update
BUNDLE` wraps rauc install and refuses to move a debug system onto a
non-debug bundle without confirmation: that install removes the SSH
channel driving it, which happened live on the bench and ended in a
stick reinstall. verify-image asserts the stamp matches its mode
(--test expects debug, release otherwise).

Covered at the owning tiers: the gate, stamp parsing and the wrapped
install run in tests/stack (19 new assertions, rauc stubbed); the
artifact stamp is a verify-image check. Docs: a variants section in
appliance-release.md, and M7 now goes through os-update.

Closes #818
Closes #819

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rink)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ror names the wrong culprit

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@VijitSingh97
VijitSingh97 merged commit 9339997 into feat/phase2-bakery-image Aug 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant