From 72e415be4cdb39ba3443adf9a4a441b5474868fe Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 6 Oct 2016 11:14:09 +1100 Subject: [PATCH] ctdb-scripts: Dump stack traces of smbd processes after shutdown If any processes remain then they may be stuck in D state and this might tell us why. Update tests: tweak pidof stub, add support for smbd stack traces and add some new tests for the shutdown event. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Mon Oct 10 12:54:24 CEST 2016 on sn-devel-144 --- ctdb/config/events.d/50.samba | 1 + .../eventscripts/50.samba.shutdown.001.sh | 12 +++++++ .../eventscripts/50.samba.shutdown.002.sh | 15 +++++++++ ctdb/tests/eventscripts/scripts/local.sh | 33 ++++++++++++++++--- ctdb/tests/eventscripts/stubs/pidof | 7 ++-- 5 files changed, 62 insertions(+), 6 deletions(-) create mode 100755 ctdb/tests/eventscripts/50.samba.shutdown.001.sh create mode 100755 ctdb/tests/eventscripts/50.samba.shutdown.002.sh diff --git a/ctdb/config/events.d/50.samba b/ctdb/config/events.d/50.samba index b521d00858f..4ed892cdc59 100755 --- a/ctdb/config/events.d/50.samba +++ b/ctdb/config/events.d/50.samba @@ -65,6 +65,7 @@ service_start () service_stop () { service "$CTDB_SERVICE_SMB" stop + program_stack_traces "smbd" 5 if [ -n "$CTDB_SERVICE_NMB" ] ; then service "$CTDB_SERVICE_NMB" stop fi diff --git a/ctdb/tests/eventscripts/50.samba.shutdown.001.sh b/ctdb/tests/eventscripts/50.samba.shutdown.001.sh new file mode 100755 index 00000000000..8c0be7c190f --- /dev/null +++ b/ctdb/tests/eventscripts/50.samba.shutdown.001.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "shutdown, simple" + +setup_samba + +ok <] fake_stack_trace_for_pid_${_pid}/stack+0x0/0xff +EOF +} + program_stack_traces () { _prog="$1" @@ -1008,10 +1036,7 @@ program_stack_traces () for _pid in ${FAKE_NFSD_THREAD_PIDS:-$FAKE_RPC_THREAD_PIDS} ; do [ $_count -le $_max ] || break - cat <] fake_stack_trace_for_pid_${_pid}/stack+0x0/0xff -EOF + program_stack_trace "$_prog" "$_pid" _count=$(($_count + 1)) done } diff --git a/ctdb/tests/eventscripts/stubs/pidof b/ctdb/tests/eventscripts/stubs/pidof index b84aef0acda..8b57923d0ba 100755 --- a/ctdb/tests/eventscripts/stubs/pidof +++ b/ctdb/tests/eventscripts/stubs/pidof @@ -1,12 +1,15 @@ #!/bin/sh case "$1" in - nfsd) +nfsd) echo "$FAKE_NFSD_THREAD_PIDS" ;; - rpc.statd|rpc.rquotad|rpc.mountd) +rpc.statd|rpc.rquotad|rpc.mountd) echo "$FAKE_RPC_THREAD_PIDS" ;; +smbd) + echo "$FAKE_SMBD_THREAD_PIDS" + ;; *) echo "pidof: \"$1\" not implemented" exit 1 -- 2.34.1