Find redhat kernel version command gives invalid output when multiple versions are installed

Bug #2065299 reported by Kevin Reeuwijk
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Triaged
Medium
Unassigned
curtin
New
Undecided
Unassigned

Bug Description

When building Rocky 9 images for MAAS, if you update the kernel in the source image and don't clean up the previous kernel version, the "rpm -q --queryformat "%{VERSION}-%{RELEASE}.%{ARCH}" kernel" command returns an invalid string like this:

# rpm -q --queryformat "%{VERSION}-%{RELEASE}.%{ARCH}" kernel
5.14.0-162.6.1.el9_1.x86_645.14.0-362.24.1.el9_3.0.1.x86_64

This causes the subsequent initramfs command to fail, resulting in a failed OS deployment:

finish: cmd-install/stage-curthooks/builtin/cmd-curthooks/updating-initramfs-configuration: FAIL: updating initramfs configuration
finish: cmd-install/stage-curthooks/builtin/cmd-curthooks: FAIL: curtin command curthooks
Traceback (most recent call last):
  File "/curtin/curtin/commands/main.py", line 202, in main
    ret = args.func(args)
  File "/curtin/curtin/commands/curthooks.py", line 1918, in curthooks
    builtin_curthooks(cfg, target, state)
  File "/curtin/curtin/commands/curthooks.py", line 1863, in builtin_curthooks
    redhat_update_initramfs(target, cfg)
  File "/curtin/curtin/commands/curthooks.py", line 1696, in redhat_update_initramfs
    in_chroot.subp(dracut_cmd, capture=True)
  File "/curtin/curtin/util.py", line 792, in subp
    return subp(*args, **kwargs)
  File "/curtin/curtin/util.py", line 280, in subp
    return _subp(*args, **kwargs)
  File "/curtin/curtin/util.py", line 144, in _subp
    raise ProcessExecutionError(stdout=out, stderr=err,
curtin.util.ProcessExecutionError: Unexpected error while running command.
Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmpms1dg_tc/target', 'dracut', '-f', '/boot/initramfs-5.14.0-162.23.1.el9_1.x86_645.14.0-362.24.1.el9_3.0.1.x86_64.img', '5.14.0-162.23.1.el9_1.x86_645.14.0-362.24.1.el9_3.0.1.x86_64']
Exit code: 1
Reason: -
Stdout: /etc/dracut.conf.d/50-curtin-storage.conf:add_dracutmodules+=" lvm"

Stderr:
        dracut: WARNING: <key>+=" <values> ": <values> should have surrounding white spaces!
        dracut: WARNING: This will lead to unwanted side effects! Please fix the configuration file.

        dracut: Cannot find module directory /lib/modules/5.14.0-162.23.1.el9_1.x86_645.14.0-362.24.1.el9_3.0.1.x86_64/
        dracut: and --no-kernel was not specified

Unexpected error while running command.

The command should be altered to something that returns only the latest installed kernel version.
For example:

# ls -t /lib/modules | head -1
5.14.0-362.24.1.el9_3.0.1.x86_64

Changed in maas:
status: New → Triaged
importance: Undecided → Medium
milestone: none → 3.6.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.