On 05/22/14 at 01:52pm, Vivek Goyal wrote:
On Mon, May 19, 2014 at 10:42:21PM +0800, WANG Chao wrote:
> Currently we disable stock emergency.service because interrupting the
> boot process will stop us from entering kdump capture script. But this
> isn't promising, when a mandatory target/service fails and emergency is
> disabled, systemd has no service to run and appears hang to us.
Because we spent so much in understanding the problem, we can put
some more info as follows.
Current kdump error handling disables emergency shell and relies on
kdump.sh being invoked through dracut-pre-pivot hook. But it might
happen that we never call into dracut-pre-pivot hook because some
targets before that could not reach due to failure in their dependencies.
In those cases error handling code does not run and system hangs.
This new scheme will overwrite emergency shell and replace with kdump
error handling code. And this code will do the error handling as needed.
Now, we will not rely on dracut-pre-pivot hook running always. Instead
whenever error happens and it is serious enough that emergency shell
needed to run, now kdump error handler will run.
Excellent! I'll change the description as yours.
>
> A better approach is to write our own error handling service and act
> different according to our configured default action in kdump.conf.
>
> This patch introduce a kdump error handling script and an emergency
> service. This emergency.service unit is overriding the existing one when
> building kdump initramfs, and when it's started it will call the error
> handling script.
>
> Signed-off-by: WANG Chao <chaowang(a)redhat.com>
> ---
> dracut-kdump-emergency.service | 32 ++++++++++++++++++++++++++++++++
> dracut-kdump-error-handler.sh | 10 ++++++++++
> dracut-module-setup.sh | 3 +++
> kexec-tools.spec | 5 ++++-
> 4 files changed, 49 insertions(+), 1 deletion(-)
> create mode 100644 dracut-kdump-emergency.service
> create mode 100755 dracut-kdump-error-handler.sh
>
> diff --git a/dracut-kdump-emergency.service b/dracut-kdump-emergency.service
> new file mode 100644
> index 0000000..a29b14a
> --- /dev/null
> +++ b/dracut-kdump-emergency.service
> @@ -0,0 +1,32 @@
> +# This file is part of systemd.
^^^^^
What does it mean. It is not part of systemd tree.
Shoot! I bindly copy the contents from the stock emergency.service.
> +#
> +# systemd is free software; you can redistribute it and/or modify it
> +# under the terms of the GNU Lesser General Public License as published by
> +# the Free Software Foundation; either version 2.1 of the License, or
> +# (at your option) any later version.
We are shipping it under kdump tree so to me it should be govered by
kdump tree license and not systemd license?
Let's delete these lines.
> +
> +# See systemd.special(7) for details
And this line too.
Thanks
WANG Chao
> +
> +[Unit]
> +Description=Kdump Error Handler
> +DefaultDependencies=no
> +After=systemd-vconsole-setup.service
> +Wants=systemd-vconsole-setup.service
> +
> +[Service]
> +Environment=HOME=/
> +Environment=DRACUT_SYSTEMD=1
> +Environment=NEWROOT=/sysroot
> +WorkingDirectory=/
> +ExecStart=/bin/kdump-error-handler.sh
> +ExecStopPost=-/usr/bin/systemctl --fail --no-block default
> +Type=oneshot
> +StandardInput=tty-force
> +StandardOutput=inherit
> +StandardError=inherit
> +KillMode=process
> +IgnoreSIGPIPE=no
> +
> +# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
> +# terminates cleanly.
> +KillSignal=SIGHUP
> diff --git a/dracut-kdump-error-handler.sh b/dracut-kdump-error-handler.sh
> new file mode 100755
> index 0000000..2c55b04
> --- /dev/null
> +++ b/dracut-kdump-error-handler.sh
> @@ -0,0 +1,10 @@
> +#!/bin/sh
> +
> +. /lib/kdump-lib.sh
> +
> +set -o pipefail
> +export PATH=$PATH:$KDUMP_SCRIPT_DIR
> +
> +get_kdump_confs
> +do_default_action
> +do_final_action
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index 2a16900..0a03bfa 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -546,6 +546,9 @@ install() {
> inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
> inst_hook pre-pivot 9999 "$moddir/kdump.sh"
> inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
> + inst "$moddir/kdump-error-handler.sh"
"/usr/bin/kdump-error-handler.sh"
> + # Replace existing emergency service
> + cp "$moddir/kdump-emergency.service"
"$initdir/$systemdsystemunitdir/emergency.service"
>
It will be interesting to see how does it go. For the time being, looks
good and let us give it a try.
> # Check for all the devices and if any device is iscsi, bring up iscsi
> # target. Ideally all this should be pushed into dracut iscsi module
> diff --git a/kexec-tools.spec b/kexec-tools.spec
> index a1490db..0e6d25c 100644
> --- a/kexec-tools.spec
> +++ b/kexec-tools.spec
> @@ -34,6 +34,8 @@ Source22: kdump-dep-generator.sh
> Source100: dracut-kdump.sh
> Source101: dracut-module-setup.sh
> Source102: dracut-monitor_dd_progress
> +Source103: dracut-kdump-error-handler.sh
> +Source104: dracut-kdump-emergency.service
>
> Requires(post): systemd-units
> Requires(preun): systemd-units
> @@ -188,7 +190,8 @@ mkdir -p -m755
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpba
> cp %{SOURCE100}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE100}}
> cp %{SOURCE101}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE101}}
> cp %{SOURCE102}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE102}}
> -
> +cp %{SOURCE103}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE103}}
> +cp %{SOURCE104}
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE104}}
> chmod 755
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE100}}
> chmod 755
$RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix
%{SOURCE101}}
>
> --
> 1.9.0
>
> _______________________________________________
> kexec mailing list
> kexec(a)lists.fedoraproject.org
>
https://lists.fedoraproject.org/mailman/listinfo/kexec