Bug 1731924 - "grubby --default-kernel" returns "rpm-sort: Invalid input /boot and exit with code 0
Summary: "grubby --default-kernel" returns "rpm-sort: Invalid input /boot and exit wit...
Keywords:
Status: ON_QA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: grubby
Version: 8.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Bootloader engineering team
QA Contact: Release Test Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-22 12:14 UTC by Michal Reznik
Modified: 2020-02-02 14:55 UTC (History)
4 users (show)

Fixed In Version: grubby-8.40-38.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)
/boot content (5.27 MB, application/gzip)
2019-07-22 12:14 UTC, Michal Reznik
no flags Details

Description Michal Reznik 2019-07-22 12:14:47 UTC
Created attachment 1592579 [details]
/boot content

Description of problem:

At the end of upgrade process from RHEL7 to RHEL8, we try to get currently set default kernel running:

# grubby --default-kernel

but if fails as follows:

rpm-sort: Invalid input 
/boot

# echo $?
0


Version-Release number of selected component (if applicable):

grubby-8.40-34.el8.x86_64

How reproducible:


Steps to Reproduce:
1. system with EFI
2. leapp upgrade (specific patch is currently needed; can be provided)
3. grubby --default-kernel

Actual results:

Command # grubby --default-kernel fails

Expected results:

Command #grubby --default-kernel returns default kernel

Additional info:

On vanilla RHEL8 the command works just fine. Attaching /boot content (without kernels and initramfs'es). 

In case any additional info is needed, please let us know.

Comment 1 Javier Martinez Canillas 2019-07-22 12:48:01 UTC
Hello Michal,

The problem is that /boot/loader/entries is empty and that's what grubby uses to determine what are the boot entries.

I agree that the error message should be improved to mention that there are no BLS snippets in /boot/loader/entries instead of this cryptic message, but I believe that's what causing your issue.

Comment 2 Pavel Odvody 2019-07-22 13:04:02 UTC
(In reply to Javier Martinez Canillas from comment #1)
> Hello Michal,
> 
> The problem is that /boot/loader/entries is empty and that's what grubby
> uses to determine what are the boot entries.
> 
> I agree that the error message should be improved to mention that there are
> no BLS snippets in /boot/loader/entries instead of this cryptic message, but
> I believe that's what causing your issue.

Thanks for looking into this, Javier, while I agree that the error message could provide more context I've been also wondering what is the correct course of action here - i.e. who/what/how is supposed to populate the BLS snippets so that we can actually upgrade EFI systems?

Comment 3 Javier Martinez Canillas 2019-07-22 13:35:04 UTC
(In reply to Pavel Odvody from comment #2)
> (In reply to Javier Martinez Canillas from comment #1)
> > Hello Michal,
> > 
> > The problem is that /boot/loader/entries is empty and that's what grubby
> > uses to determine what are the boot entries.
> > 
> > I agree that the error message should be improved to mention that there are
> > no BLS snippets in /boot/loader/entries instead of this cryptic message, but
> > I believe that's what causing your issue.
> 
> Thanks for looking into this, Javier, while I agree that the error message
> could provide more context I've been also wondering what is the correct
> course of action here - i.e. who/what/how is supposed to populate the BLS
> snippets so that we can actually upgrade EFI systems?

I'm not that familiar with Leapp but on a vanilla RHEL8 the BLS snippets are populated by the kernel-install script when a kernel package is installed.

There's also a grub2-switch-to-blscfg script that can be used to switch a grub configuration from non-BLS to BLS. This script also will populate the BLS snippets among other things.

Comment 4 Ina 2019-10-30 12:01:22 UTC
Seeing that bug again with uefi http://pastebin.test.redhat.com/809957

```
[  188.031165] upgrade[390]: 2019-10-30 07:43:18.202 DEBUG    PID: 624 leapp.workflow.Finalization.kernelcmdlineconfig: External command has started: ['grubby', '--update-kernel=/boot/vmlinuz-4.18.0-147.el8.x86_64', '--args=net.ifnames=0']
[  188.054036] upgrade[390]: rpm-sort: Invalid input
[  188.068491] upgrade[390]: The param /boot/vmlinuz-4.18.0-147.el8.x86_64 is incorrect
```

Comment 5 Javier Martinez Canillas 2019-10-31 09:05:46 UTC
(In reply to Ina from comment #4)
> Seeing that bug again with uefi http://pastebin.test.redhat.com/809957
> 
> ```
> [  188.031165] upgrade[390]: 2019-10-30 07:43:18.202 DEBUG    PID: 624
> leapp.workflow.Finalization.kernelcmdlineconfig: External command has
> started: ['grubby', '--update-kernel=/boot/vmlinuz-4.18.0-147.el8.x86_64',
> '--args=net.ifnames=0']
> [  188.054036] upgrade[390]: rpm-sort: Invalid input
> [  188.068491] upgrade[390]: The param /boot/vmlinuz-4.18.0-147.el8.x86_64
> is incorrect
> ```

This seems to be caused by /boot/loader/entries not having any BLS config file.

Can you please share the content of your /boot/loader/entries directory as well as the following files /boot/grub2/grubenv and /etc/grub2-efi.cfg ?

Comment 6 Ina 2019-10-31 09:10:54 UTC
(In reply to Javier Martinez Canillas from comment #5)
> (In reply to Ina from comment #4)
> > Seeing that bug again with uefi http://pastebin.test.redhat.com/809957
> > 
> > ```
> > [  188.031165] upgrade[390]: 2019-10-30 07:43:18.202 DEBUG    PID: 624
> > leapp.workflow.Finalization.kernelcmdlineconfig: External command has
> > started: ['grubby', '--update-kernel=/boot/vmlinuz-4.18.0-147.el8.x86_64',
> > '--args=net.ifnames=0']
> > [  188.054036] upgrade[390]: rpm-sort: Invalid input
> > [  188.068491] upgrade[390]: The param /boot/vmlinuz-4.18.0-147.el8.x86_64
> > is incorrect
> > ```
> 
> This seems to be caused by /boot/loader/entries not having any BLS config
> file.
> 
> Can you please share the content of your /boot/loader/entries directory as
> well as the following files /boot/grub2/grubenv and /etc/grub2-efi.cfg ?


Sorry for not giving all the details in the previous comment - you are absolutely right, empty /boot/loader/entries was the cause of the failure. Yesterday I workarounded that as you advised earlier, by calling grub2-switch-to-blscfg before executing the grubby command.

Comment 7 Javier Martinez Canillas 2019-11-27 16:29:53 UTC
(In reply to Ina from comment #6)
> (In reply to Javier Martinez Canillas from comment #5)
> > (In reply to Ina from comment #4)
> > > Seeing that bug again with uefi http://pastebin.test.redhat.com/809957
> > > 
> > > ```
> > > [  188.031165] upgrade[390]: 2019-10-30 07:43:18.202 DEBUG    PID: 624
> > > leapp.workflow.Finalization.kernelcmdlineconfig: External command has
> > > started: ['grubby', '--update-kernel=/boot/vmlinuz-4.18.0-147.el8.x86_64',
> > > '--args=net.ifnames=0']
> > > [  188.054036] upgrade[390]: rpm-sort: Invalid input
> > > [  188.068491] upgrade[390]: The param /boot/vmlinuz-4.18.0-147.el8.x86_64
> > > is incorrect
> > > ```
> > 
> > This seems to be caused by /boot/loader/entries not having any BLS config
> > file.
> > 
> > Can you please share the content of your /boot/loader/entries directory as
> > well as the following files /boot/grub2/grubenv and /etc/grub2-efi.cfg ?
> 
> 
> Sorry for not giving all the details in the previous comment - you are
> absolutely right, empty /boot/loader/entries was the cause of the failure.
> Yesterday I workarounded that as you advised earlier, by calling
> grub2-switch-to-blscfg before executing the grubby command.

Thanks for confirming. But still grubby shouldn't print a cryptic error message in this case, that would only confuse users.

Comment 8 Petr Janda 2019-11-29 14:41:56 UTC
Reproduced on RHEL-8.2-20191120.0 x86_64

By following steps:
1) install RHEL-8.2 (EFI is not needed)
2) cp -a /boot/loader/entries /boot/loader/entries.backup
3) grubby --default-kernel

it prints
rpm-sort: Invalid input
/boot

message and exits with code 0

providing qa_ack

As a note: I think in such case grubby should exit with different exit code.

Comment 9 Javier Martinez Canillas 2019-11-29 14:56:00 UTC
(In reply to Petr Janda from comment #8)
> Reproduced on RHEL-8.2-20191120.0 x86_64
> 
> By following steps:
> 1) install RHEL-8.2 (EFI is not needed)
> 2) cp -a /boot/loader/entries /boot/loader/entries.backup
> 3) grubby --default-kernel
> 
> it prints
> rpm-sort: Invalid input
> /boot
> 
> message and exits with code 0
> 
> providing qa_ack
>

Thanks a lot.
 
> As a note: I think in such case grubby should exit with different exit code.

I'm not sure if grubby should consider not finding any entries an error. So at least for this bug I would just like to avoid printing the cryptic / confusing message.


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