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
6 changes: 6 additions & 0 deletions crates/lib/src/bootc_composefs/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,12 @@ fn write_systemd_uki_config(
}

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.

// its file name, so writing ours wouldn't overwrite it
esp_dir
.remove_all_optional(TYPE1_ENT_PATH_STAGED)
.with_context(|| format!("Removing {TYPE1_ENT_PATH_STAGED}"))?;

esp_dir
.create_dir_all(TYPE1_ENT_PATH_STAGED)
.with_context(|| format!("Creating {TYPE1_ENT_PATH_STAGED}"))?;
Expand Down
35 changes: 35 additions & 0 deletions tmt/tests/booted/test-composefs-gc-uki.nu
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,42 @@ let booted = $st.status.booted.image
let uki_prefix = "bootc_composefs-"

let is_uki = (($st.status.booted.composefs.bootType | str downcase) == "uki")
let is_sdboot = (($st.status.booted.composefs.bootloader | str downcase) == "systemd")

if not $is_uki {
exit 0
}

# Build an image with this VERSION_ID and stage it
def stage_version [version: string] {
let containerfile = $"
FROM localhost/bootc as base
RUN sed -i 's/^VERSION_ID=.*/VERSION_ID=($version)/' /usr/lib/os-release
"

(tap make_uki_containerfile $containerfile) | podman build -t $"localhost/bootc-($version)" . -f -

bootc switch --transport containers-storage $"localhost/bootc-($version)"
}

# A UKI's boot entry has the version from its os-release in its file name, so
# staging an image of another version doesn't overwrite the staged entry. Make
# sure that entry goes away, along with the deployment it belongs to.
def restage_another_version [] {
stage_version "restage1"
let replaced = (bootc status --json | from json).status.staged.composefs.verity

stage_version "restage2"

let staged = (glob /var/tmp/efi/loader/entries.staged/*.conf)
assert equal ($staged | length) 2 $"Expected the new and booted entries, found ($staged)"
assert (not ($staged | any { |f| $f | str contains "restage1" }))

let status = (bootc status --json | from json).status
assert ($status.staged.image.image.image | str ends-with "bootc-restage2")
assert (not ($"/sysroot/state/deploy/($replaced)" | path exists))
}

# Create a large file in a new container image, then bootc switch to the image
def first_boot [] {
bootc image copy-to-storage
Expand Down Expand Up @@ -171,6 +202,10 @@ def fourth_boot [] {
let path = cat /var/large-file-marker-objpath
assert (not ($path | path exists))

if $is_sdboot {
restage_another_version
}

tap ok
}

Expand Down
Loading