From 9545f9ac49f186ab58396a6bfa20baa066d43765 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Fri, 16 Dec 2022 16:36:55 +0100 Subject: [PATCH] scripts: Ignore RLIMIT_CORE while writing out core dumps As stated in the core(5) the RLIMIT_CORE is not enforced when kernel is piping core to the collector, hence it will be written out even when it's set to 0. Instead of playing nice and checking the validity of RLIMIT_CORE, simply ignore it and apply our own limit (2GB). This is done for convenience and to make sure that any changes to the way how given distro applies limits (see fedora37) to the processes doesn't affect our core collection. Signed-off-by: Michal Berger Change-Id: Iab8757f548f2a4f0f4b27b4ce66b0a4a84ed2579 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15994 Reviewed-by: Konrad Sztyber Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- autotest.sh | 2 +- scripts/core-collector.sh | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/autotest.sh b/autotest.sh index bbcafacc6..c15094dc2 100755 --- a/autotest.sh +++ b/autotest.sh @@ -36,7 +36,7 @@ if [ $(uname -s) = Linux ]; then # Dump the $output_dir path to a file so collector can pick it up while executing. # We don't set in in the core_pattern command line because of the string length limitation # of 128 bytes. See 'man core 5' for details. - echo "|$rootdir/scripts/core-collector.sh %P %s %t %c" > /proc/sys/kernel/core_pattern + echo "|$rootdir/scripts/core-collector.sh %P %s %t" > /proc/sys/kernel/core_pattern echo "$output_dir/coredumps" > "$rootdir/.coredump_path" # make sure nbd (network block device) driver is loaded if it is available diff --git a/scripts/core-collector.sh b/scripts/core-collector.sh index 27cd4cdba..0b1ccafc4 100755 --- a/scripts/core-collector.sh +++ b/scripts/core-collector.sh @@ -7,7 +7,7 @@ # can include whitespaces or other funny characters, and working # with those on the cmdline would be a nightmare. Use procfs for # the remaining pieces we want to gather: -# |$rootdir/scripts/core-collector.sh %P %s %t %c $output_dir +# |$rootdir/scripts/core-collector.sh %P %s %t $output_dir core_meta() { jq . <<- CORE @@ -34,7 +34,6 @@ stderr() { args+=(core_pid) args+=(core_sig) args+=(core_ts) -args+=(rlimit) read -r "${args[@]}" <<< "$*" @@ -50,13 +49,8 @@ stderr # RLIMIT_CORE is not enforced when core is piped to us. To make # sure we won't attempt to overload underlying storage, copy # only the reasonable amount of bytes (systemd defaults to 2G -# so let's follow that). But first, check limits of terminating -# process to see if we need to make any adjustments. -max_core=$((1024 * 1024 * 1024 * 2)) - -if ((rlimit == 0xffffffffffffffff || rlimit > max_core)); then - rlimit=$max_core -fi +# so let's follow that). +rlimit=$((1024 * 1024 * 1024 * 2)) # Clear path for lz rm -f "$core"{,.{bin,bt,gz,json}}