RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1929838 - what is the proper usage of 'boom create' with --grub-id
Summary: what is the proper usage of 'boom create' with --grub-id
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: boom-boot
Version: 8.4
Hardware: x86_64
OS: Linux
medium
low
Target Milestone: rc
: ---
Assignee: Bryn M. Reeves
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-02-17 18:38 UTC by Corey Marthaler
Modified: 2021-11-10 09:26 UTC (History)
5 users (show)

Fixed In Version: boom-boot-1.3-2.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-09 19:51:13 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:4456 0 None None None 2021-11-09 19:51:15 UTC

Description Corey Marthaler 2021-02-17 18:38:02 UTC
Description of problem:
Based on boom help and mentioned in bug 1848123, grub-id should be supported now.
            [--grub-id ID] [-H] [-P PROFILE] [--host-name HOSTNAME] [-i IMG]


What is the proper way to use it?


[root@hayes-01 ~]# lvs -a -o +devices
  LV        VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices
  boom_snap snapper swi-a-s--- 100.00m      origin 0.00                                    /dev/md0p1(75)
  origin    snapper owi-a-s--- 300.00m                                                     /dev/md0p1(0)
[root@hayes-01 ~]# lvs -a -o +devices,segtype
  LV        VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices        Type
  boom_snap snapper swi-a-s--- 100.00m      origin 0.00                                    /dev/md0p1(75) linear
  origin    snapper owi-a-s--- 300.00m                                                     /dev/md0p1(0)  linear

[root@hayes-01 ~]# boom -h
usage: boom [-h] [-a OPTIONS] [--all] [--architecture ARCH] [--backup]
            [...]
            [--grub-id ID] [-H] [-P PROFILE] [--host-name HOSTNAME] [-i IMG]


[root@hayes-01 ~]# boom create --title 13 --grub-id 347 --root-lv /dev/snapper/boom_snap
WARNING - Boom grub2 integration is disabled in '/boot/../etc/default/boom'
Profile with os_id='4abe4f7' does not support None
ERROR - Command failed: OsProfile os_id=4abe4f7 does not allow 'id'
[root@hayes-01 ~]# echo $?
1

[root@hayes-01 ~]# boom create --title 14 --grub-users 347 --root-lv /dev/snapper/boom_snap
WARNING - Boom grub2 integration is disabled in '/boot/../etc/default/boom'
Created entry with boot_id 0b24c0e:
  title 14
  machine-id 02b079f3d054487fb8c1268adcd18a3f
  version 4.18.0-287.el8.x86_64
  linux /vmlinuz-4.18.0-287.el8.x86_64
  initrd /initramfs-4.18.0-287.el8.x86_64.img
  options root=/dev/snapper/boom_snap ro rd.lvm.lv=snapper/boom_snap rhgb quiet
  grub_users 347
  grub_arg --unrestricted
  grub_class kernel
[root@hayes-01 ~]# echo $?
0


Version-Release number of selected component (if applicable):
boom-boot-1.3-1.el8    BUILT: Sat Jan 30 02:31:18 CST 2021

Comment 1 Bryn M. Reeves 2021-02-19 18:03:48 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:

Comment 2 Bryn M. Reeves 2021-02-19 18:56:53 UTC
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>

Comment 8 Corey Marthaler 2021-06-16 21:56:33 UTC
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

Comment 11 Corey Marthaler 2021-06-24 19:11:38 UTC
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)

Comment 12 Bryn M. Reeves 2021-06-28 15:19:50 UTC
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.

Comment 13 Corey Marthaler 2021-07-06 19:55:36 UTC
Marking verified based on explanation provided above in comment #12.

Comment 16 errata-xmlrpc 2021-11-09 19:51:13 UTC
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


Note You need to log in before you can comment on or make changes to this bug.