Don't try to update crashkernel when bootloader is not installed

Resolves: bz2060319
Upstream: Fedora
Conflict: commit a3da46d6 ("Skip reset_crashkernel_after_update
          during package install") hasn't been backported. Note it's now
          no longer needed.

commit 5951b5e26823b6bedf3237bd169a781b03f25031
Author: Coiby Xu <coxu@redhat.com>
Date:   Tue Dec 20 13:59:18 2022 +0800

    Don't try to update crashkernel when bootloader is not installed

    Currently when using anaconda to install the OS, the following errors
    occur,

        INF packaging: Configuring (running scriptlet for): kernel-core-5.14.0-70.el9.x86_64 ...
        INF dnf.rpm: grep: /boot/grub2/grubenv: No such file or directory
        grep: /boot/grub2/grubenv: No such file or directory
        grep: /boot/grub2/grubenv: No such file or directory
        grep: /boot/grub2/grubenv: No such file or directory
        ...
        INF packaging: Configuring (running scriptlet for): kexec-tools-2.0.23-9.el9.x86_64 ...
        INF dnf.rpm: grep: /boot/grub2/grubenv: No such file or directory
        grep: /boot/grub2/grubenv: No such file or directory
        grep: /boot/grub2/grubenv: No such file or directory

    Or for s390, the following errors occur,

        INF packaging: Configuring (running scriptlet for): kernel-core-5.14.0-71.el9.s390x ...
        03:37:51,232 INF dnf.rpm: grep: /etc/zipl.conf: No such file or directory
        grep: /etc/zipl.conf: No such file or directory
        grep: /etc/zipl.conf: No such file or directory

        INF packaging: Configuring (running scriptlet for): kexec-tools-2.0.23-9_1.el9_0.s390x ...
        INF dnf.rpm: grep: /etc/zipl.conf: No such file or directory

    This is because when anaconda installs the packages, bootloader hasn't
    been installed and /boot/grub2/grubenv or /etc/zipl.conf doesn't exist.
    So don't try to update crashkernel when bootloader isn't ready to avoid
    the above errors.

    Note this is the second attempt to fix this issue. Previously a file
    /tmp/kexec_tools_package_install was created to avoid running the
    related code thus to avoid the above errors but unfortunately that
    approach has two issues a) somehow osbuild doesn't delete it for RHEL b)
    this file could still exist if users manually remove kexec-tools.

    Fixes: e218128 ("Only try to reset crashkernel for osbuild during package install")
    Reported-by: Jan Stodola <jstodola@redhat.com>
    Signed-off-by: Coiby Xu <coxu@redhat.com>
    Reviewed-by: Philipp Rudo <prudo@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Coiby Xu 2022-12-20 13:59:18 +08:00 committed by Pingfan Liu
parent 06ddf8d90d
commit e120508100
2 changed files with 11 additions and 13 deletions

View File

@ -1638,10 +1638,13 @@ reset_crashkernel()
fi
}
# to tell if it's package install other than upgrade
_is_package_install()
_is_bootloader_installed()
{
[[ -f /tmp/kexec_tools_package_install ]]
if [[ $(uname -r) == s390x ]]; then
test -f /etc/zipl.conf
else
test -f /boot/grub2/grub.cfg
fi
}
# update the crashkernel value in GRUB_ETC_DEFAULT if necessary
@ -1653,10 +1656,6 @@ update_crashkernel_in_grub_etc_default_after_update()
local _crashkernel _fadump_val
local _dump_mode _old_default_crashkernel _new_default_crashkernel
if _is_package_install; then
return
fi
if [[ $(uname -m) == s390x ]]; then
return
fi
@ -1686,6 +1685,10 @@ reset_crashkernel_after_update()
local _kernel _crashkernel _dump_mode _fadump_val _old_default_crashkernel _new_default_crashkernel
declare -A _crashkernel_vals
if ! _is_bootloader_installed; then
return
fi
_crashkernel_vals[old_kdump]=$(cat /tmp/old_default_crashkernel 2> /dev/null)
_crashkernel_vals[old_fadump]=$(cat /tmp/old_default_crashkernel_fadump 2> /dev/null)
_crashkernel_vals[new_kdump]=$(get_default_crashkernel kdump)
@ -1738,7 +1741,7 @@ reset_crashkernel_for_installed_kernel()
# During package install, only try to reset crashkernel for osbuild
# thus to avoid calling grubby when installing os via anaconda
if _is_package_install && ! _is_osbuild; then
if ! _is_bootloader_installed && ! _is_osbuild; then
return
fi

View File

@ -283,11 +283,6 @@ if [ ! -f /run/ostree-booted ] && [ $1 == 2 ] && grep -q get-default-crashkernel
kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null
%endif
fi
# indicate it's package install so kdumpctl later will only reset crashkernel
# value for osbuild.
if [ $1 == 1 ]; then
touch /tmp/kexec_tools_package_install
fi
# don't block package update
: