Skip to content

Rollback Fixes#2213

Open
Johan-Liebert1 wants to merge 5 commits into
bootc-dev:mainfrom
Johan-Liebert1:rollback-fix
Open

Rollback Fixes#2213
Johan-Liebert1 wants to merge 5 commits into
bootc-dev:mainfrom
Johan-Liebert1:rollback-fix

Conversation

@Johan-Liebert1

Copy link
Copy Markdown
Collaborator

cfs/rollback: Remove staged entry on rollback

Similar to ostree, if we find any staged deployment while performing
a rollback, we'll get rid of the staged deployment. The staged
deployment still exists on disk and will be GC'd later

Fixes: #2208


cfs/status: Implement bootloader-specific sorting

Update get_sorted_type1_boot_entries_helper to implement sorting
logic based on bootloader type

  • systemd-boot: Sort by sort-key (using BLSConfig::cmp which handles
    sort-key ascending, then version descending)
  • GRUB: Sort by filename in descending order (ignoring sort-key fields)

Unit Tests generated by ClaudeCode (Opus)

@Johan-Liebert1 Johan-Liebert1 requested a review from cgwalters May 26, 2026 10:14
@Johan-Liebert1 Johan-Liebert1 added the ci/tier-1 Run CI for tier-1 OS (centos-10) only label May 26, 2026
@bootc-bot bootc-bot Bot requested a review from jeckersb May 26, 2026 10:14

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements dropping staged deployments on rollback to match ostree's behavior, updates boot entry sorting logic to sort based on the bootloader type (by sort-key for systemd-boot and by filename for GRUB), and adds corresponding unit and integration tests. The reviewer identified a robustness issue in rollback.rs where stale staged entries might not be cleaned up if host.status.staged is None and the rollback could fail unnecessarily if the staged deployment file is already missing. Additionally, a maintainability issue was found in status.rs where the comments in the GRUB sorting test contradict the actual assertions and sorting behavior.

Comment thread crates/lib/src/bootc_composefs/rollback.rs
Comment thread crates/lib/src/bootc_composefs/status.rs
@Johan-Liebert1

Copy link
Copy Markdown
Collaborator Author

GHA seems to be having issues

// Ostree will drop any staged deployment on rollback
// We follow the same approach for now
if let Some(..) = &host.status.staged {
println!("Removing currently staged deployment");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd like to try to centralize reporting more in the future and get away from just random println!. This isn't the only case of course.

One thing we could probably do instead here is log to the journal, which would have other benefits.

Comment thread crates/lib/src/bootc_composefs/rollback.rs
Similar to ostree, if we find any staged deployment while performing
a rollback, we'll get rid of the staged deployment. The staged
deployment still exists on disk and will be GC'd later

Fixes: bootc-dev#2208

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Add a case in the rollback test which tests rollback when there is a
staged deployment present. This is a test for bootc-dev#2208

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Update `get_sorted_type1_boot_entries_helper` to implement sorting
logic based on bootloader type

- systemd-boot: Sort by sort-key (using BLSConfig::cmp which handles
    sort-key ascending, then version descending)
- GRUB: Sort by filename in descending order (ignoring sort-key fields)

Unit Tests generated by ClaudeCode (Opus)

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Instead of blindly selecting the "second" one in a list of sorted boot
entries as the rollback and failing if there are more than one rollback
candidate, sort the rollback candidates in the same order as the boot
entries and take the first one as rollback.

All the remaining deployments become `other_deployments`. This is
especially useful if and when we implement pinned deployments for
composefs

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
@Johan-Liebert1 Johan-Liebert1 force-pushed the rollback-fix branch 2 times, most recently from 2408645 to 9e127ff Compare June 1, 2026 12:27
cgwalters
cgwalters previously approved these changes Jun 1, 2026
Comment thread crates/lib/src/bootc_composefs/status.rs
If we are unable to find the origin file for a deployment, we were
immediately exiting with an error which rendered any bootc operation
useless. Instead, just log a warning in the journal and continue with
the specified operation so that we don't completely stop working if the
system is in an unpredictable state

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/tier-1 Run CI for tier-1 OS (centos-10) only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ComposeFS backend] Series of rebases/updates into bootc rollback breaks bootc (persisting through reboots)

2 participants