Skip to content

composefs: Replace a staged UKI's boot entries - #2630

Merged
Johan-Liebert1 merged 1 commit into
bootc-dev:mainfrom
krissedout:composefs-staged-entries
Nov 11, 2026
Merged

Johan-Liebert1 merged 1 commit into
bootc-dev:mainfrom
krissedout:composefs-staged-entries

Conversation

@krissedout

@krissedout krissedout commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Staging an update over one that's already staged, with a different version, leaves bootc status failing with "Opening OCI image for manifest sha256:...: No such file or directory". bootc upgrade and bootc switch fail with the same error, and a reboot doesn't help: it comes back on the old deployment with status still failing, so the machine can't take any more updates. This happens with UKIs under systemd-boot, for example when a timer stages a new build before anyone has rebooted into the last one.

A boot entry's file name carries the version from the UKI's os-release, and write_systemd_uki_config() adds to loader/entries.staged without clearing it, so the earlier staged entry stays next to the new one. Status then finds a deployment that's neither staged nor rollback, GC drops its image while the entry and state directory stay, and the next status can't open its manifest. #1857 reported the entries stacking up and #1861 fixed that for Type 1 entries with a kernel and initrd, but UKIs go through a different function. Images whose version doesn't change, like a stream of Fedora builds all with VERSION_ID=45, overwrite the same file name and never hit this.

This removes the staged entries before writing the new ones, the same way setup_composefs_bls_boot() does.

On this branch cargo fmt --check, cargo check --workspace --all-targets, cargo test -p bootc-lib -p bootc-internal-blockdev and just validate pass. There's no unit test because the function needs a booted deployment and a real bootloader, so the coverage is in test-composefs-gc-uki.nu: with systemd-boot, its last boot stages two images with different VERSION_IDs, then checks that loader/entries.staged only has the new and booted entries and that the replaced deployment's state is gone.

I ran it with an image from just build on fedora-bootc:45 (composefs, systemd-boot, unsealed UKI, ext4), with SELinux enforcing. On main it fails with three entries in loader/entries.staged, and status, upgrade and switch all fail with the error above, also after rebooting. With this change it passes through the reboot, and status, GC and bootc upgrade behave normally afterwards. I don't have bcvk or libvirt on this machine, so rather than through just test-tmt I installed with bootc install to-disk from a helper VM and ran the script stage by stage in qemu, with the fixed bootc bind-mounted over /usr/bin/bootc. I didn't run it on centos-bootc stream10 or with a sealed UKI.

Assisted-by: AI
I reviewed and tested the changes myself.

@Johan-Liebert1 Johan-Liebert1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great to move the tmt test into the gc test

}

BootSetupType::Upgrade((_, booted_cfs, ..)) => {
// An earlier staged deployment's entry may have another version in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. it'd be better to find a function lower on the stack where we do this, but that's more of a cleanup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed it'd be cleaner further down, I'd rather do that as a follow-up so this fix doesn't wait on it, if that's ok.

Staging a UKI wrote its entries into loader/entries.staged next to
whatever an earlier staged deployment left there. An entry's file name
carries the version from the UKI's os-release, so staging an image of
another version over a staged one kept the earlier entry. Status then
found a deployment that was neither staged nor rollback, garbage
collection removed its image while its entry and state directory
stayed, and from then on status failed to open the manifest. Upgrade,
switch and finalization all go through status, so the system was stuck
on the booted deployment, and rebooting didn't help.

Remove the staged entries before writing the new ones, as
setup_composefs_bls_boot() has done since bootc-dev#1861.

Assisted-by: AI
Signed-off-by: Kristof Imeri <kristof@lanth.me>
@krissedout
krissedout force-pushed the composefs-staged-entries branch from 311c753 to 58f8074 Compare November 10, 2026 22:52
@Johan-Liebert1
Johan-Liebert1 merged commit cf06a12 into bootc-dev:main Nov 11, 2026
58 checks passed
@krissedout
krissedout deleted the composefs-staged-entries branch November 11, 2026 14:34
krissedout added a commit to krissedout/bootc that referenced this pull request Nov 11, 2026
setup_composefs_bls_boot() and write_systemd_uki_config() each had
their own copy of writing a deployment's Type 1 entry: into
loader/entries on install, or, when staging, into a fresh
loader/entries.staged next to the booted deployment's entry. The UKI
copy only started clearing the earlier staged entries in bootc-dev#2630, after
the BLS one had done so since bootc-dev#1861.

Move it into write_type1_entries(), which both now call, so the two
can't drift apart again. It also fsyncs the entries directory it wrote
to for UKIs too, where it used to fsync the ESP's root.

Assisted-by: AI
Signed-off-by: Kristof Imeri <kristof@lanth.me>
cgwalters pushed a commit that referenced this pull request Nov 13, 2026
setup_composefs_bls_boot() and write_systemd_uki_config() each had
their own copy of writing a deployment's Type 1 entry: into
loader/entries on install, or, when staging, into a fresh
loader/entries.staged next to the booted deployment's entry. The UKI
copy only started clearing the earlier staged entries in #2630, after
the BLS one had done so since #1861.

Move it into write_type1_entries(), which both now call, so the two
can't drift apart again. It also fsyncs the entries directory it wrote
to for UKIs too, where it used to fsync the ESP's root.

Assisted-by: AI
Signed-off-by: Kristof Imeri <kristof@lanth.me>
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.

2 participants