Add failure_action as alias of default and make default obsolete

In preparation for adding 'final_action' option, since it's confusing
to have the 'final_action' and 'default' options at the same time,
this patch introduces 'failure_action' as an alias of the 'default'
option to /etc/kdump.conf, and makes 'default' obsolete to be removed
in the future.

Also, the "default action" term is renamed to "failure action".

Signed-off-by: Kazuhito Hagio <k-hagio@ab.jp.nec.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Lianbo Jiang <lijiang@redhat.com>
Cc: Bhupesh Sharma <bhsharma@redhat.com>
Acked-by: Bhupesh Sharma <bhsharma@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
Kazuhito Hagio 2019-01-17 15:31:23 -05:00 committed by Kairui Song
parent 0c24dce730
commit cc95f0a744
9 changed files with 68 additions and 46 deletions

View File

@ -6,7 +6,7 @@
# (at your option) any later version. # (at your option) any later version.
# This service will run the real kdump error handler code. Executing the # This service will run the real kdump error handler code. Executing the
# default action configured in kdump.conf # failure action configured in kdump.conf
[Unit] [Unit]
Description=Kdump Error Handler Description=Kdump Error Handler

View File

@ -6,5 +6,5 @@ set -o pipefail
export PATH=$PATH:$KDUMP_SCRIPT_DIR export PATH=$PATH:$KDUMP_SCRIPT_DIR
get_kdump_confs get_kdump_confs
do_default_action do_failure_action
do_final_action do_final_action

View File

@ -71,8 +71,8 @@ The control flow of fadump works as follows:
process.) process.)
09. Captures dump according to /etc/kdump.conf 09. Captures dump according to /etc/kdump.conf
10. Is dump capture successful (yes goto 12, no goto 11) 10. Is dump capture successful (yes goto 12, no goto 11)
11. Perfom the default action specified in /etc/kdump.conf (Default action 11. Perform the failure action specified in /etc/kdump.conf
is reboot, if unspecified) (The default failure action is reboot, if unspecified)
12. Reboot 12. Reboot
@ -227,12 +227,12 @@ to initate the dump and then click "Restart blade with NMI". This issues a
system reset and invokes xmon debugger. system reset and invokes xmon debugger.
Advanced Setups & Default action: Advanced Setups & Failure action:
Kdump and fadump exhibit similar behavior in terms of setup & default action. Kdump and fadump exhibit similar behavior in terms of setup & failure action.
For fadump advanced setup related information see section "Advanced Setups" in For fadump advanced setup related information see section "Advanced Setups" in
"kexec-kdump-howto.txt" document. Refer to "Default action" section in "kexec- "kexec-kdump-howto.txt" document. Refer to "Failure action" section in "kexec-
kdump-howto.txt" document for fadump default action related information. kdump-howto.txt" document for fadump failure action related information.
Compression and filtering Compression and filtering

View File

@ -6,7 +6,7 @@ KDUMP_PATH="/var/crash"
CORE_COLLECTOR="" CORE_COLLECTOR=""
DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31" DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31"
DMESG_COLLECTOR="/sbin/vmcore-dmesg" DMESG_COLLECTOR="/sbin/vmcore-dmesg"
DEFAULT_ACTION="systemctl reboot -f" FAILURE_ACTION="systemctl reboot -f"
DATEDIR=`date +%Y-%m-%d-%T` DATEDIR=`date +%Y-%m-%d-%T`
HOST_IP='127.0.0.1' HOST_IP='127.0.0.1'
DUMP_INSTRUCTION="" DUMP_INSTRUCTION=""
@ -51,22 +51,22 @@ get_kdump_confs()
fence_kdump_nodes) fence_kdump_nodes)
FENCE_KDUMP_NODES="$config_val" FENCE_KDUMP_NODES="$config_val"
;; ;;
default) failure_action|default)
case $config_val in case $config_val in
shell) shell)
DEFAULT_ACTION="kdump_emergency_shell" FAILURE_ACTION="kdump_emergency_shell"
;; ;;
reboot) reboot)
DEFAULT_ACTION="systemctl reboot -f" FAILURE_ACTION="systemctl reboot -f"
;; ;;
halt) halt)
DEFAULT_ACTION="halt" FAILURE_ACTION="halt"
;; ;;
poweroff) poweroff)
DEFAULT_ACTION="systemctl poweroff -f" FAILURE_ACTION="systemctl poweroff -f"
;; ;;
dump_to_rootfs) dump_to_rootfs)
DEFAULT_ACTION="dump_to_rootfs" FAILURE_ACTION="dump_to_rootfs"
;; ;;
esac esac
;; ;;
@ -159,10 +159,10 @@ kdump_emergency_shell()
rm -f /etc/profile rm -f /etc/profile
} }
do_default_action() do_failure_action()
{ {
echo "Kdump: Executing default action $DEFAULT_ACTION" echo "Kdump: Executing failure action $FAILURE_ACTION"
eval $DEFAULT_ACTION eval $FAILURE_ACTION
} }
do_final_action() do_final_action()

View File

@ -149,10 +149,10 @@ get_block_dump_target()
is_dump_to_rootfs() is_dump_to_rootfs()
{ {
grep "^default[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null grep -E "^(failure_action|default)[[:space:]]dump_to_rootfs" /etc/kdump.conf >/dev/null
} }
get_default_action_target() get_failure_action_target()
{ {
local _target local _target
@ -181,7 +181,7 @@ get_kdump_targets()
fi fi
# Add the root device if dump_to_rootfs is specified. # Add the root device if dump_to_rootfs is specified.
_root=$(get_default_action_target) _root=$(get_failure_action_target)
if [ -n "$_root" -a "$kdump_targets" != "$_root" ]; then if [ -n "$_root" -a "$kdump_targets" != "$_root" ]; then
kdump_targets="$kdump_targets $_root" kdump_targets="$kdump_targets $_root"
fi fi

View File

@ -6,8 +6,8 @@
# processed. # processed.
# #
# Currently, only one dump target and path can be specified. If the dumping to # Currently, only one dump target and path can be specified. If the dumping to
# the configured target fails, the default action which can be configured via # the configured target fails, the failure action which can be configured via
# the "default" directive will be performed. # the "failure_action" directive will be performed.
# #
# Supported options: # Supported options:
# #
@ -99,7 +99,7 @@
# Multiple modules can be listed, separated by spaces, and any # Multiple modules can be listed, separated by spaces, and any
# dependent modules will automatically be included. # dependent modules will automatically be included.
# #
# default <reboot | halt | poweroff | shell | dump_to_rootfs> # failure_action <reboot | halt | poweroff | shell | dump_to_rootfs>
# - Action to perform in case dumping fails. # - Action to perform in case dumping fails.
# reboot: Reboot the system. # reboot: Reboot the system.
# halt: Halt the system. # halt: Halt the system.
@ -110,6 +110,10 @@
# reboot. Useful when non-root dump target is specified. # reboot. Useful when non-root dump target is specified.
# The default option is "reboot". # The default option is "reboot".
# #
# default <reboot | halt | poweroff | shell | dump_to_rootfs>
# - Same as the "failure_action" directive above, but this directive
# is obsolete and will be removed in the future.
#
# force_rebuild <0 | 1> # force_rebuild <0 | 1>
# - By default, kdump initrd will only be rebuilt when necessary. # - By default, kdump initrd will only be rebuilt when necessary.
# Specify 1 to force rebuilding kdump initrd every time when kdump # Specify 1 to force rebuilding kdump initrd every time when kdump
@ -155,7 +159,7 @@ core_collector makedumpfile -l --message-level 1 -d 31
#kdump_pre /var/crash/scripts/kdump-pre.sh #kdump_pre /var/crash/scripts/kdump-pre.sh
#extra_bins /usr/bin/lftp #extra_bins /usr/bin/lftp
#extra_modules gfs2 #extra_modules gfs2
#default shell #failure_action shell
#force_rebuild 1 #force_rebuild 1
#force_no_rebuild 1 #force_no_rebuild 1
#dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3" #dracut_args --omit-drivers "cfg80211 snd" --add-drivers "ext2 ext3"

View File

@ -148,7 +148,7 @@ modules can be listed, separated by spaces, and any
dependent modules will automatically be included. dependent modules will automatically be included.
.RE .RE
.B default <reboot | halt | poweroff | shell | dump_to_rootfs> .B failure_action <reboot | halt | poweroff | shell | dump_to_rootfs>
.RS .RS
Action to perform in case dumping to the intended target fails. The default is "reboot". Action to perform in case dumping to the intended target fails. The default is "reboot".
reboot: Reboot the system (this is what most people will want, as it returns the system reboot: Reboot the system (this is what most people will want, as it returns the system
@ -156,10 +156,16 @@ to a normal state). halt: Halt the system and lose the vmcore. poweroff: The s
will be powered down. shell: Drop to a shell session inside the initramfs, from which will be powered down. shell: Drop to a shell session inside the initramfs, from which
you can manually perform additional recovery actions. Exiting this shell reboots the you can manually perform additional recovery actions. Exiting this shell reboots the
system. Note: kdump uses bash as the default shell. dump_to_rootfs: If non-root dump system. Note: kdump uses bash as the default shell. dump_to_rootfs: If non-root dump
target is specified, the default action can be set as dump_to_rootfs. That means when target is specified, the failure action can be set as dump_to_rootfs. That means when
dumping to target fails, dump vmcore to rootfs from initramfs context and reboot. dumping to target fails, dump vmcore to rootfs from initramfs context and reboot.
.RE .RE
.B default <reboot | halt | poweroff | shell | dump_to_rootfs>
.RS
Same as the "failure_action" directive above, but this directive is obsolete
and will be removed in the future.
.RE
.B force_rebuild <0 | 1> .B force_rebuild <0 | 1>
.RS .RS
By default, kdump initrd will only be rebuilt when necessary. By default, kdump initrd will only be rebuilt when necessary.

View File

@ -228,7 +228,7 @@ check_config()
case "$config_opt" in case "$config_opt" in
\#* | "") \#* | "")
;; ;;
raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes) raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|failure_action|default|force_rebuild|force_no_rebuild|dracut_args|fence_kdump_args|fence_kdump_nodes)
# remove inline comments after the end of a directive. # remove inline comments after the end of a directive.
config_val=$(strip_comments $config_val) config_val=$(strip_comments $config_val)
[ -z "$config_val" ] && { [ -z "$config_val" ] && {
@ -247,7 +247,7 @@ check_config()
esac esac
done < $KDUMP_CONFIG_FILE done < $KDUMP_CONFIG_FILE
check_default_config || return 1 check_failure_action_config || return 1
check_fence_kdump_config || return 1 check_fence_kdump_config || return 1
@ -935,23 +935,35 @@ start_dump()
return $? return $?
} }
check_default_config() check_failure_action_config()
{ {
local default_option local default_option
local failure_action
local option="failure_action"
default_option=$(awk '$1 ~ /^default$/ {print $2;}' $KDUMP_CONFIG_FILE) default_option=$(awk '$1 ~ /^default$/ {print $2;}' $KDUMP_CONFIG_FILE)
if [ -z "$default_option" ]; then failure_action=$(awk '$1 ~ /^failure_action$/ {print $2;}' $KDUMP_CONFIG_FILE)
if [ -z "$failure_action" -a -z "$default_option" ]; then
return 0 return 0
else elif [ -n "$failure_action" -a -n "$default_option" ]; then
case "$default_option" in echo "Cannot specify 'failure_action' and 'default' option together"
reboot|halt|poweroff|shell|dump_to_rootfs) return 1
return 0
;;
*)
echo $"Usage kdump.conf: default {reboot|halt|poweroff|shell|dump_to_rootfs}"
return 1
esac
fi fi
if [ -n "$default_option" ]; then
option="default"
failure_action="$default_option"
fi
case "$failure_action" in
reboot|halt|poweroff|shell|dump_to_rootfs)
return 0
;;
*)
echo $"Usage kdump.conf: $option {reboot|halt|poweroff|shell|dump_to_rootfs}"
return 1
esac
} }
start() start()

View File

@ -463,21 +463,21 @@ storage device, such as an iscsi target disk or clustered file system, you may
need to manually specify additional kernel modules to load into your kdump need to manually specify additional kernel modules to load into your kdump
initrd. initrd.
Default action Failure action
============== ==============
Default action specifies what to do when dump to configured dump target Failure action specifies what to do when dump to configured dump target
fails. By default, default action is "reboot" and that is system reboots fails. By default, failure action is "reboot" and that is system reboots
if attempt to save dump to dump target fails. if attempt to save dump to dump target fails.
There are other default actions available though. There are other failure actions available though.
- dump_to_rootfs - dump_to_rootfs
This option tries to mount root and save dump on root filesystem This option tries to mount root and save dump on root filesystem
in a path specified by "path". This option will generally make in a path specified by "path". This option will generally make
sense when dump target is not root filesystem. For example, if sense when dump target is not root filesystem. For example, if
dump is being saved over network using "ssh" then one can specify dump is being saved over network using "ssh" then one can specify
default to "dump_to_rootfs" to try saving dump to root filesystem failure action to "dump_to_rootfs" to try saving dump to root
if dump over network fails. filesystem if dump over network fails.
- shell - shell
Drop into a shell session inside initramfs. Drop into a shell session inside initramfs.