From 5f9ce8fea9592cf21730bb0ae1ace31aa3f82365 Mon Sep 17 00:00:00 2001 From: Bernard Ogden Date: Fri, 12 Dec 2014 10:19:17 +0000 Subject: Encapsulate decision to keep lava session in runbenchmark.sh This script knows whether it has cleaned up as it wants to. It now sends a different signal to lava.sh to tell it to terminate with job cancellation. We default to NOT cancelling the job, so if anything goes wrong we will be able to investigate. --- scripts/lava.sh | 12 +++++++----- scripts/runbenchmark.sh | 9 +++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/lava.sh b/scripts/lava.sh index 7782503..62ae21f 100755 --- a/scripts/lava.sh +++ b/scripts/lava.sh @@ -14,7 +14,9 @@ if test $? -ne 0; then fi listener_pid= waiter= +keep=1 error=1 +trap 'keep=0; exit ${error}' USR1 trap release EXIT trap 'exit ${error}' TERM INT HUP QUIT @@ -47,8 +49,10 @@ release() error=1 fi else - echo "Did not cancel job ${id} - keep requested" - echo "Run 'lava-tool cancel-job https://"${lava_server}" "${id}"' to cancel" + echo "Did not cancel job ${id} - superior did not request cancellation." + echo "You probably have some cleanup to do." + echo "When you've finished, cancel by running:" + echo "lava-tool cancel-job https://${lava_server} ${id}" error=0 fi fi @@ -58,14 +62,12 @@ release() lava_server="${LAVA_SERVER}" lava_json= boot_timeout="$((120*60))" #2 hours -keep=0 key=${LAVA_SSH_KEYFILE} -while getopts s:j:b:kp: flag; do +while getopts s:j:b:p: flag; do case "${flag}" in s) lava_server="${OPTARG}";; j) lava_json="${OPTARG}";; b) boot_timeout="$((OPTARG*60))";; - k) keep=1;; p) key="${OPTARG}";; *) echo 'Unknown option' 1>&2 diff --git a/scripts/runbenchmark.sh b/scripts/runbenchmark.sh index 7cfb831..0b9c620 100755 --- a/scripts/runbenchmark.sh +++ b/scripts/runbenchmark.sh @@ -110,11 +110,12 @@ clean_benchmark() if test x"${lava_pid}" != x; then if test ${lava_release} -ne 0; then - echo "Not killing lava.sh, to ensure session remains open for cleanup." - echo "You can kill it with 'kill ${lava_pid}'." - else + echo "Not killing lava session, to ensure session remains open for cleanup." kill "${lava_pid}" wait "${lava_pid}" + else + kill -USR1 "${lava_pid}" + wait "${lava_pid}" fi #Make sure we see any messages from the lava.sh handlers @@ -165,7 +166,7 @@ if test $? -eq 0; then echo "Acquiring LAVA target ${lava_target}" echo "${topdir}/scripts/lava.sh -s ${lavaserver} -j ${confdir}/${lava_target} -b ${boot_timeout:-30}" - ${topdir}/scripts/lava.sh -s "${lavaserver}" -j "${confdir}/${lava_target}" -b "${boot_timeout-:30}" ${keep} >&4 & #Don't enquote keep - if it is empty we want to pass nothing, not the empty string + ${topdir}/scripts/lava.sh -s "${lavaserver}" -j "${confdir}/${lava_target}" -b "${boot_timeout-:30}" >&4 & if test $? -ne 0; then echo "+++ Failed to acquire LAVA target ${lava_target}" 1>&2 exit 1 -- cgit v1.2.3