Skip to content

Conversation

martinezjavier
Copy link
Contributor

The bootc images generated by automotive-image-builder for x86_64 are only meant to be booted using an EFI firmware and the ukiboot boot protocol.

The images don't support neither legacy BIOS nor grub2. But currently, the osbuild manifests used by automotive-image-builder must include the grub2 packages just to avoid bootupd to fail when attempting to generate the update metadata and install the listed components for x86_64.

This merge request relaxes this requirement, making the BIOS component metadata update and installation optional. Instead of bailing out if the expected grub2 tools are not present or there is no update metadata for the BIOS component.

Currently, the `bootupctl backend generate-update-metadata` command tries
to generate an update layout for each component, and it bails out if one
of the components can't be installed.

There are systems in which some of the bootupd components are not needed
(e.g.: x86_64 EFI-only systems). But if one of the requirements for one
of the components is not meet (e.g.: grub2-install is missing for BIOS),
this will lead to a fatal error instead of just skipping the component
that is not supported.

To prevent this, let's make the update layout generation to be optional.

Signed-off-by: Javier Martinez Canillas <[email protected]>
Copy link

openshift-ci bot commented Sep 25, 2025

Hi @martinezjavier. Thanks for your PR.

I'm waiting for a coreos member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 refactors the boot component handling to allow skipping BIOS component installation when grub2 is not present, which is useful for EFI-only images. The changes correctly make generate_update_metadata return an Option and handle this in the calling code.

My review includes two main points:

  1. In src/bootupd.rs, there's a potential bug where errors from query_update are silently ignored. I've suggested a fix to properly propagate these errors.
  2. In src/bios.rs, I've recommended using the log crate instead of println! for a diagnostic message to improve logging consistency and control.

Overall, the changes are in the right direction to achieve the goal. Addressing these points will improve the robustness and maintainability of the code.

src/bootupd.rs Outdated
Comment on lines 97 to 103
if let Ok(None) = component.query_update(&source_root_dir) {
println!(
"Skip installing component {} without update metadata",
component.name()
);
continue;
}

Choose a reason for hiding this comment

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

high

The use of if let Ok(None) = ... here can silently swallow errors. If component.query_update() returns an Err, the condition is false, and execution proceeds to component.install(), which will likely fail again but with a potentially more obscure error message. This makes debugging harder. It's better to handle the Err case explicitly, for instance by using the ? operator to propagate the error.

Suggested change
if let Ok(None) = component.query_update(&source_root_dir) {
println!(
"Skip installing component {} without update metadata",
component.name()
);
continue;
}
if component.query_update(&source_root_dir)?.is_none() {
println!(
"Skip installing component {} without update metadata",
component.name()
);
continue;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did the suggested change.

Comment on lines +133 to +134
println!("Failed to find {:?}", grub_install);
return Ok(None);

Choose a reason for hiding this comment

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

medium

Using println! for this diagnostic message can add noise to the standard output, which is primarily used for user-facing progress messages. It's better to use the log crate for such messages. This provides more control over verbosity and separates diagnostic output from application output. The calling function in bootupd.rs already prints a user-friendly message about skipping the component.

Note: You will need to add use log; at the top of the file.

Suggested change
println!("Failed to find {:?}", grub_install);
return Ok(None);
log::info!("Skipping BIOS metadata generation; grub2-install not found at {:?}", grub_install);
return Ok(None);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the println!() macro to be consistent with how other similar messages were printed.

@cgwalters
Copy link
Member

Thanks for filing this! This also relates to #978

Now that update metadata generation is optional for some components,
skip installing the components that don't have an update metadata.
Instead of making it a fatal error, just make the component to be skipped.

This allows to generate the update metadata for other components, instead
of failing due not being able to generate the metadata for BIOS component.
@martinezjavier martinezjavier force-pushed the optional-update-metadata branch from 6afe758 to f9de0fd Compare September 25, 2025 16:23
@martinezjavier
Copy link
Contributor Author

Thanks for filing this! This also relates to #978

Note that this MR is only about handling the legacy BIOS case since for UEFI we have a different workaround. But yes, decoupling the EFI component from grub2 (and shim?) would be ideal too.

Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Thanks! One minor nit we can just change post merge.

let grub_install = Path::new(sysroot_path).join(GRUB_BIN);
if !grub_install.exists() {
bail!("Failed to find {:?}", grub_install);
println!("Failed to find {:?}", grub_install);
Copy link
Member

Choose a reason for hiding this comment

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

How about: Skipping, executable not found: {:?} (it's not a failure) - as you've used elsewhere in the PR

continue;
}

// skip components that don't have an update metadata
Copy link
Member

Choose a reason for hiding this comment

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

Hmm this one is interesting. I think actually the problem is we're iterating over the static list of components, when actually I think we should just accept whatever the updated components in the updates set are to start with or so.

Although it raises a different point - it would probably make sense in the future to handle the case where a component is removed. (e.g. an OS update drops out BIOS support and we would then in theory clear out the BIOS partition e.g.)

And to do that, we do need to iterate over the components we know (as this is doing) and intersect them with the update set.

@cgwalters
Copy link
Member

/ok-to-test

@cgwalters cgwalters enabled auto-merge September 26, 2025 20:06
@cgwalters cgwalters merged commit 2352767 into coreos:main Sep 26, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants