From d56516e8e5a2062db2ba8e3359ef7b717e6dd4ba Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 1 Nov 2024 15:48:52 +0800 Subject: [PATCH] Set up crashkernel value for osbuild Resolves: https://issues.redhat.com/browse/RHEL-63071 Conflict: None Upstream Status: git@github.com:rhkdump/kdump-utils.git commit c196f5b9ebacbd60ef61ab20bfe399065e2de96b Author: Coiby Xu Date: Wed Oct 23 10:48:05 2024 +0800 Set up crashkernel value for osbuild Resolves: https://issues.redhat.com/browse/RHEL-63071 Currently the cloud image built by osbuild doesn't have crashkernel set up. Since kdumpctl will set up crashkernel only when kdump.service is enabled, it will fail if it's done in the following order -> kernel's %posttrans scriptlet -> 92-crashkernel.install -> kdumpctl _reset-crashkernel-for-installed_kernel -> kdump-utils' %post scriptlet enables kdump.serivce This patch now let "systemd preset" kdump.service in the %post scriptlet instead. So when the kernel's %posttrans scriptlet is running, kdump.service is already enabled. %posttrans runs after all packages' %post scriptlets have been executed [1], so now crashkernel is set up in the following order, kdump-utils' post scriptlet which "systemd preset" kdump.service -> kernel's posttrans RPM scriptlet -> 92-crashkernel.install -> kdumpctl _reset-crashkernel-for-installed_kernel And we expect users have now upgraded to kdump-utils so there is no need for the solution introduced in commit 5fe098fe. Note an agreement has been reached between kdump-utils and osbuild in https://bugzilla.redhat.com/show_bug.cgi?id=2024976 that kdump-utils will be responsible for setting up the crashkernel kernel parameter. And since kdump-utils will only set up crashkernel when kdump.service is enabled, we need to make sure kdump.service is enabled in the systemd preset. [1] https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#ordering Fixes: 5fe098fe ("Don't systemctl preset kdump when updating kexec-tools to kdump-utils") Signed-off-by: Coiby Xu Signed-off-by: Coiby Xu --- kdump-utils.spec | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/kdump-utils.spec b/kdump-utils.spec index f56698f..85094c8 100644 --- a/kdump-utils.spec +++ b/kdump-utils.spec @@ -50,16 +50,8 @@ target. %post -# don't try to systemctl preset the kdump service for old kexec-tools -# -# when the old kexec-tools gets removed, this trigger will be excuted to -# create a file. So later the posttrans scriptlet will know there is no need to -# systemctl preset the kdump service. -# This solution can be dropped in F41 when we assume no users will use old -# version of kexec-tools. -%define kexec_tools_no_preset %{_localstatedir}/lib/rpm-state/kexec-tools.no-preset -%triggerun -- kexec-tools -touch %{kexec_tools_no_preset} +# kdumpctl will only set up default crashkernel when kdump.service is enabled +%systemd_post kdump.service touch /etc/kdump.conf @@ -79,14 +71,6 @@ servicelog_notify --remove --command=/usr/lib/kdump/kdump-migrate-action.sh >/de %systemd_preun kdump.service %posttrans -# don't try to systemctl preset the kdump service for old kexec-tools -if [[ -f %{kexec_tools_no_preset} ]]; then - # this if branch can be removed in F41 when we assume no users will use the old kexec-tools - rm %{kexec_tools_no_preset} -else - # Initial installation - %systemd_post kdump.service -fi # Try to reset kernel crashkernel value to new default value or set up # crasherkernel value for new install # @@ -94,6 +78,7 @@ fi # 1. Skip ostree systems as they are not supported. # 2. For Fedora 36 and RHEL9, "[ $1 == 1 ]" in posttrans scriptlet means both install and upgrade; # For Fedora > 36, "[ $1 == 1 ]" only means install and "[ $1 == 2 ]" means upgrade +# 3. osbuild depends on "kdumpctl _reset-crashkernel-for-installed_kernel" to set up crashkernel if [ ! -f /run/ostree-booted ] && [ $1 == 1 -o $1 == 2 ]; then kdumpctl _reset-crashkernel-after-update :