Use grubby to update kernel command line arguments - #511
Conversation
Use "grubby --update-kernel=ALL" to update kernel arguments on BLS-based systems such as RHEL 10, where grub2-mkconfig does not propagate them to `/boot/loader/entries`. Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
| "sed -i '/cloud-init=disabled/d' %s" % grub_conf_disabler | ||
| ) | ||
| self._schedule_grub2_update() | ||
| self._update_kernel_cmdline_args(args_to_remove=["cloud-init=disabled"]) |
There was a problem hiding this comment.
I don't like that both grub update and grubby are being called. It should be the one or the other, not both.
An ideal implementation would be to call for _update_kernel_cmdline_args indeed, but you only implemented it for redhat based. There should also be a debian implementation which does the former (reads /etc/default/grub, removes/adds/edits the cmdline, schedules grub2 update).
I propose the following:
-
Use Grub2ConfigEditor whenever possible instead of
sed-ing the file directly.
This implies implementing a new method to remove cmdline entries, call itremove_from_option
This method should pretty much emulate what grubby does on redhat, and that is if you pass a single option
(--remove-args=cloud-init), then it will be removed even if it's a key_val, no matter what value cloud-init has
in cmdline. If you pass a key_val, then only remove the key if the value matches
(--remove-args=cloud-init=disabledonly remove cloud-init from cmdline if it's disabled, but won't
removecloud-init=enabled). -
We should somehow abstractize this for redhat. On base, when calling for
_update_kernel_cmdline_args,
it should instantiate a Grub2ConfigEditor, append or remove from GRUB_CMDLINE_LINUX and
GRUB_CMDLINE_LINUX_DEFAULT options (depending on what args_to_add or args_to_remove are being
passed).
If it's redhat, then simply use grubby to handle args_to_add/args_to_remove -
(only if grubby commands take too long, otherwise treat this as optional) I think the final grubby command should also be run once at the end, so add some
schedule_grubby
methods as well when adding args to remove/add. (similar to_schedule_grub2_update)
Failing to update the kernel console options breaks text console functionality on affected platforms.
The issue is caused by BLS being enabled by default in
/etc/default/grub. OnRHEL 10, kernel arguments are managed through/boot/loader/entries, andgrub2-mkconfigdoes not propagate the updated options there.This PR implements the following:
grubby --update-kernel=ALLto update kernel arguments on BLS-based systems.grub2-mkconfiglogic whengrubbyis not available.