Bug 1929838
| Summary: | what is the proper usage of 'boom create' with --grub-id | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Corey Marthaler <cmarthal> |
| Component: | boom-boot | Assignee: | Bryn M. Reeves <bmr> |
| Status: | CLOSED ERRATA | QA Contact: | cluster-qe <cluster-qe> |
| Severity: | low | Docs Contact: | |
| Priority: | medium | ||
| Version: | 8.4 | CC: | agk, bmr, cmackows, jbrassow, mcsontos |
| Target Milestone: | rc | Flags: | pm-rhel:
mirror+
|
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | boom-boot-1.3-2.el8 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2021-11-09 19:51:13 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
|
Description
Corey Marthaler
2021-02-17 18:38:02 UTC
There's a couple of things going on here. There's quite a long/complicated story around the "id" key (a Red Hat extension to the BootLoaderSpecification) but the behaviour you're seeing is basically correct. This message:
ERROR - Command failed: OsProfile os_id=4abe4f7 does not allow 'id'
Is saying that the RHEL8 OsProfile does not allow the optional 'id' key. Displaying the profile confirms that "id" is not in the optional keys list:
# boom profile show 4abe
OS Profile (os_id=4abe4f7)
OS ID: "4abe4f7fd38fc7506cbe2f42b1b85d54af3b29b1",
Name: "Red Hat Enterprise Linux", Short name: "rhel",
Version: "8 (Ootpa)", Version ID: "8",
Kernel pattern: "/vmlinuz-%{version}", Initramfs pattern: "/initramfs-%{version}.img",
Root options (LVM2): "rd.lvm.lv=%{lvm_root_lv}",
Root options (BTRFS): "rootflags=%{btrfs_subvolume}",
Options: "root=%{root_device} ro %{root_opts} rhgb quiet",
Title: "%{os_name} %{os_version_id} (%{version})",
Optional keys: "grub_users grub_class grub_arg", UTS release pattern: "el8"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
When I added the other optional keys I decided to not enable "id" by default since it is undocumented, unused by the Grub2 bootloader in RHEL, and has been removed from later Fedora versions. If a user does have a need to set it then it can be enabled by editing the OsProfile:
# boom profile edit 4abe --optional-keys "grub_users grub_class grub_arg id"
Edited profile:
OS ID: "4abe4f7fd38fc7506cbe2f42b1b85d54af3b29b1",
Name: "Red Hat Enterprise Linux", Short name: "rhel",
Version: "8 (Ootpa)", Version ID: "8",
Kernel pattern: "/vmlinuz-%{version}", Initramfs pattern: "/initramfs-%{version}.img",
Root options (LVM2): "rd.lvm.lv=%{lvm_root_lv}",
Root options (BTRFS): "rootflags=%{btrfs_subvolume}",
Options: "root=%{root_device} ro %{root_opts} rhgb quiet",
Title: "%{os_name} %{os_version_id} (%{version})",
Optional keys: "grub_users grub_class grub_arg id", UTS release pattern: "el8"
And the --grub-id argument can then be passed to "boom create" commands that use this OsProfile:
# boom create --title "RHEL Snapshot" --rootlv "rhel/root-snap" --grub-id rhel-snapshot-20200625210904-4.18.0-221.el8.x86_64
Created entry with boot_id d0177e3:
title RHEL Snapshot
machine-id cf7a42448c9e405e9e224864034a07df
version 4.18.0-221.el8.x86_64
linux /vmlinuz-4.18.0-221.el8.x86_64
initrd /initramfs-4.18.0-221.el8.x86_64.img
options root=/dev/rhel/root-snap ro rd.lvm.lv=rhel/root-snap rhgb quiet
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel
id rhel-snapshot-20200625210904-4.18.0-221.el8.x86_64
The other message that you saw:
Profile with os_id='4abe4f7' does not support None
Is a bit unhelpful - it should read:
Profile with os_id='4abe4f7' does not support --grub-id
This is my fault: since the Red Hat BLS key extensions do not always match the command line argument name (i.e. "--grub-arg" -> "grub_arg" but "--grub-id" -> "id") there is a table that maps optional key names to command line arguments. The table is missing the entry for the "id" key, and the function that calls it passes the wrong form of the key identifier, causing the returned command line argument to always be "None".
The fix is trivial and I will add a test case for this upstream:
diff --git a/boom/command.py b/boom/command.py
index c9c2f6b..feb5b65 100644
--- a/boom/command.py
+++ b/boom/command.py
@@ -1883,7 +1883,8 @@ def _optional_key_to_arg(optional_key):
_key_map = {
BOOM_ENTRY_GRUB_USERS: "--grub-users",
BOOM_ENTRY_GRUB_ARG: "--grub-arg",
- BOOM_ENTRY_GRUB_CLASS: "--grub-class"
+ BOOM_ENTRY_GRUB_CLASS: "--grub-class",
+ BOOM_ENTRY_GRUB_ID: "--grub-id"
}
return _key_map[optional_key] if optional_key in _key_map else None
@@ -1914,7 +1915,7 @@ def _set_optional_key_defaults(profile, cmd_args):
if bls_key not in profile.optional_keys:
if getattr(cmd_args, bls_key) is not None:
print("Profile with os_id='%s' does not support %s" %
- (profile.disp_os_id, _optional_key_to_arg(bls_key)))
+ (profile.disp_os_id, _optional_key_to_arg(opt_key)))
return 1
else:
if getattr(cmd_args, bls_key) is None:
I've added a pair of new case to tests.command_tests: test__optional_key_to_arg_valid and test__optional_key_to_arg_invalid, the first fails with boom-1.3:
======================================================================
FAIL: test__optional_key_to_arg_valid (tests.command_tests.CommandHelperTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/breeves/src/git/boom/tests/command_tests.py", line 256, in test__optional_key_to_arg_valid
self.assertEqual(_optional_key_to_arg(opt_key),
AssertionError: None != '--grub-id'
This passes when run with the patch in comment #1:
Ran 422 tests in 16.660s
OK (skipped=4)
commit e9e675e222ab119e3d604b59c7c1a20ceacb1c95 (HEAD -> main)
Author: Bryn M. Reeves <bmr>
Date: Fri Feb 19 18:52:51 2021 +0000
command: fix optional BLS key to command line argument decoding
When reporting errors relating to the use of optional BLS keys
(i.e. --grub-users, --grub-class, --grub-arg, --grub-id) the boom
command module translates the symbolic name of the key to a user
level command line argument, for e.g.:
Profile with os_id='4abe4f7' does not support --grub-id
This is broken in boom-1.2 since the table is missing the entry
for the --grub-id argument, and the _set_optional_key_defaults()
function that calls it passes the incorrect form of the key
identifier (the BLS key name, rather than the boom API name for
the key).
Fix the table and the call, and add a test case to confirm that
the proper value is returned when decoding optional key names.
Signed-off-by: Bryn M. Reeves <bmr>
Marking Verified:Tested in the latest rpms. boom-boot-1.3-2.el8 BUILT: Tue Jun 15 08:24:06 CDT 2021 boom profile create --from-host --uname-pattern el8 Enable the usage of grub-id by using 'boom profile edit' for OS: f9e44dd boom profile edit f9e44dd --optional-keys 'grub_users grub_class grub_arg id' # --grub-id: boom create --title 13 --grub-id 400 --root-lv /dev/snapper/boom_snap boom entry show 8d3e042 --expand-variables Expanded boom list: Boot Entry (boot_id=8d3e042) title 13 machine-id 587d87eeb74645f6a7395f9f7679b6ec version 4.18.0-310.el8.x86_64 linux /vmlinuz-4.18.0-310.el8.x86_64 initrd /initramfs-4.18.0-310.el8.x86_64.img options root=/dev/snapper/boom_snap ro rd.lvm.lv=snapper/boom_snap rhgb quiet id 400 grub_users grub_arg --unrestricted grub_class kernel boom entry show 8d3e042 Boot Entry (boot_id=8d3e042) title 13 machine-id 587d87eeb74645f6a7395f9f7679b6ec version 4.18.0-310.el8.x86_64 linux /vmlinuz-4.18.0-310.el8.x86_64 initrd /initramfs-4.18.0-310.el8.x86_64.img options root=/dev/snapper/boom_snap ro rd.lvm.lv=snapper/boom_snap rhgb quiet id 400 grub_users $grub_users grub_arg --unrestricted grub_class kernel boom delete 8d3e042 Just a note that final verification of this is likely blocked until bug 1974885 is sorted out. Apparently grub-id can only be run on: 4abe4f7 Red Hat Enterprise Linux 8 (Ootpa) And not: f9e44dd Red Hat Enterprise Linux 8.5 (Ootpa) Your custom RHEL8.5 profile doesn't have the Red Hat optional keys set because "el8.5" is not an allowed RHEL kernel release string (they are either elN, for y-stream or elN_M for z-stream, but we can't use that to distinguish between y and z-stream kernels in boom for the reasons explained in bug 1974885). Whatever --uname-pattern you use must match the expected kernel version strings for the distribution, so for e.g. "el8" matches "kernel-4.18.0-310.el8.x86_64" but "el8.5" does not. The packaged RHEL8 profile (4abe4f7) _does_ have those optional keys set and will work as you expect. You do not need to set up any RHEL8 OsProfile for testing since bug 1842626. If you do want to set up a custom profile then it must have a uname_pattern of either "el8" (the same as 4abe4f7), to match any RHEL8 kernel, or "el8_5" if you _only_ want it to be used for RHEL8.5 z-stream kernels (afaik no such kernels exist currently - they will begin to use this naming convention after 8.6 is released, if we continue to release 8.5 z-stream packages). If you use that uname pattern then the optional keys will be enabled automatically, or you can force enable them when creating the profile by adding --optional-keys "grub_users grub_arg grub_class id" to the "boom profile create" command line. Marking verified based on explanation provided above in comment #12. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (boom-boot bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2021:4456 |