-
Notifications
You must be signed in to change notification settings - Fork 149
composefs/boot: Fix sd-boot order on update #1779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
I'm also working on adding tests for these cases |
There was a problem hiding this comment.
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 fixes the boot order for sd-boot during an update by setting the correct sort-key for BLS entries. The change correctly handles the different sorting behaviors of Grub (descending) and systemd-boot (ascending). The logic is sound. I've added one suggestion to refactor duplicated logic to improve code maintainability.
f427fb7 to
3222da9
Compare
Grub sorts its BLS config in descending order, while sd-boot sorts the configs in ascending order. While upgrading we were always setting the new sort key to be `1` which would work for Grub but not for sd-boot. Fixes: bootc-dev#1777 Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
3222da9 to
ad86fc8
Compare
| .context("Computing boot digest")?; | ||
|
|
||
| let default_sort_key = "1"; | ||
| let default_sort_key = bootloader.default_sort_key(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think it'd be cleaner if computed all the BLS entries without writing them, and then walk over all of them and reverse the order if we detect grub or so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is kind of what we're doing, but in a bit of a weird way. This might be good for a cleanup. I'll pick it up
| pub(crate) const GRUB_SECONDARY_SORT_KEY: &str = "0"; | ||
|
|
||
| /// Sort key for the primary BLS entry | ||
| pub(crate) fn default_sort_key(&self) -> &str { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
sorting_keys(&self) -> impl Iterator<Item=&'static str> {
let r = ["0", "1"]
match self {
Systemd => r
Grub => r.rev()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the secondary keys when upgrading/switching, so this doesn't quite work for that case
|
OK first when talking about grub, there's a giant mess there because it has a wildly varying patch set per distro/OS. In particular https://src.fedoraproject.org/rpms/grub2 now has 390 (!) patches. Anyways I think the real problem here is: i.e. at least Fedora's grub2 isn't implementing We should make this at least build or runtime configurable probably in the future, but for now until we gather more data on grub on other OSes it's likely simplest to just not emit |
cgwalters
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
|
From what I can see, this patch doesn't change the current behaviour for Grub, but fixes the currently broken behaviour for systemd-boot. Is it worth getting this in first and then dealing with Grub as a separate PR if more info is needed before figuring out the best solution for Grub? |
That's what's happening, at least in fedora based images. The |
Yes I think that's true, however I think it's well worth some further cleanups here. We'll get this fixed soon. |
Grub sorts its BLS config in descending order, while sd-boot sorts the configs in ascending order. While upgrading we were always setting the new sort key to be
1which would work for Grub but not for sd-boot.Fixes: #1777