Skip to content

Conversation

@Mstrodl
Copy link
Contributor

@Mstrodl Mstrodl commented Oct 22, 2025

Can be used to provide hooks into a sysroot deploy for tools like bootupd to perform bootloader swaps.

Happy to do this a different way, but this is how we've been doing it on our debian-based system. I understand bootupd is supposed to work a different way. We do it this way because grub-mkconfig will generate a broken config for the older version of grub.

See #3496 for motivation

@openshift-ci
Copy link

openshift-ci bot commented Oct 22, 2025

Hi @Mstrodl. Thanks for your PR.

I'm waiting for a github.com 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.

Details

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.

@Mstrodl Mstrodl changed the title Add support for bootloader-plugin Add hooks for deployment steps to allow bootloader swapping Oct 22, 2025
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 adds support for a bootloader-plugin by introducing hooks into the deployment process. The overall logic is sound, with hooks for deploy and swap actions placed at appropriate stages. My main feedback concerns code duplication in the plugin invocation logic, which could be refactored into a helper function for better maintainability. Additionally, the path to the plugin executable is hardcoded, and making it configurable would enhance flexibility for different system layouts.

Comment on lines 2455 to 2484
const char *const bootplugin_deploy_argv[] = { "/usr/lib/ostree/bootloader-plugin", "deploy", NULL };
bootplugin_exists = g_file_test(bootplugin_deploy_argv[0], G_FILE_TEST_EXISTS);
if (bootplugin_exists)
{
if (!g_spawn_sync(NULL, (char **) bootplugin_deploy_argv, NULL, G_SPAWN_CHILD_INHERITS_STDERR,
NULL, NULL, NULL, NULL, &estatus, error)) {
return glnx_prefix_error (error, "bootloader-plugin deploy exec failed");
}
if (!g_spawn_check_exit_status (estatus, error)) {
return glnx_prefix_error (error, "bootloader-plugin deploy failed");
}
}

if (!full_system_sync (self, cancellable, error))
return FALSE;

if (!swap_bootloader (self, bootloader, self->bootversion, new_bootversion, cancellable, error))
return FALSE;

const char *const bootplugin_swap_argv[] = { bootplugin_deploy_argv[0], "swap", NULL };
if (bootplugin_exists)
{
if (!g_spawn_sync(NULL, (char **) bootplugin_swap_argv, NULL, G_SPAWN_CHILD_INHERITS_STDERR,
NULL, NULL, NULL, NULL, &estatus, error)) {
return glnx_prefix_error (error, "bootloader-plugin swap exec failed");
}
if (!g_spawn_check_exit_status (estatus, error)) {
return glnx_prefix_error (error, "bootloader-plugin swap failed");
}
}

Choose a reason for hiding this comment

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

medium

This block of code has a couple of areas for improvement:

  • Code Duplication: The logic for spawning the bootloader-plugin for both deploy and swap actions is nearly identical. This duplicated code should be refactored into a static helper function to improve maintainability and reduce redundancy. The helper could take the command arguments and an action name (e.g., "deploy") to generate contextual error messages.

  • Hardcoded Path: The plugin path "/usr/lib/ostree/bootloader-plugin" is hardcoded within bootplugin_deploy_argv. This reduces portability. Consider defining this path as a const char* at the top of the function and making it configurable via the repository's config file, falling back to the current hardcoded path if not specified.

@Mstrodl
Copy link
Contributor Author

Mstrodl commented Oct 22, 2025

By the way if this is not something you guys want to take, that's fine too. I just figured other people might find it useful too :)

Can be used to provide hooks into a sysroot deploy for tools like
bootupd to perform bootloader swaps.

Happy to do this a different way, but this is how we've been doing
it on our debian-based system. I understand bootupd is supposed to
work a different way. We do it this way because grub-mkconfig will
generate a broken config for the older version of grub.
@Mstrodl Mstrodl force-pushed the feature/mstrodl/bootplugin branch from 56b1834 to 379f414 Compare October 22, 2025 15:00
@champtar
Copy link
Collaborator

One important info from #3496 that you forgot to repeat here is that Debian version of grub doesn't support BLS (yet), so you can't use bootupd static config :(

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