From: Peter Amstutz Date: Fri, 4 Nov 2016 14:06:09 +0000 (-0400) Subject: Improve error handling and reporting in run-cwl-test.sh script. no issue # X-Git-Url: https://git.arvados.org/arvados-dev.git/commitdiff_plain/688d8cd7d751459ddb7190aa612879847353f47e Improve error handling and reporting in run-cwl-test.sh script. no issue # --- diff --git a/jenkins/run-cwl-test.sh b/jenkins/run-cwl-test.sh index 068acd8..f5ffefe 100755 --- a/jenkins/run-cwl-test.sh +++ b/jenkins/run-cwl-test.sh @@ -1,7 +1,10 @@ #!/bin/bash +set -o pipefail + DEBUG=0 SSH_PORT=22 +ACCT=ci function usage { echo >&2 @@ -11,6 +14,7 @@ function usage { echo >&2 echo >&2 "$0 options:" echo >&2 " -p, --port SSH port to use (default 22)" + echo >&2 " --acct Account to log in with" echo >&2 " -d, --debug Enable debug output" echo >&2 " -h, --help Display this help and exit" echo >&2 @@ -27,7 +31,7 @@ function usage { echo >&2 "\"POST /arvados/v1/collections\"," echo >&2 "\"POST /arvados/v1/links\"," echo >&2 "\"GET /arvados/v1/users/current\"," - echo >&2 "\"POST /arvados/v1/users/current\"," + echo >&2 "\"POST /arvados/v1/users/current\"," echo >&2 "\"GET /arvados/v1/jobs\"," echo >&2 "\"POST /arvados/v1/jobs\"," echo >&2 "\"GET /arvados/v1/pipeline_instances\"," @@ -35,13 +39,13 @@ function usage { echo >&2 "\"POST /arvados/v1/pipeline_instances\"," echo >&2 "\"GET /arvados/v1/collections/\"," echo >&2 "\"POST /arvados/v1/collections/\"," - echo >&2 "\"GET /arvados/v1/logs\" ]" + echo >&2 "\"GET /arvados/v1/logs\" ]" echo >&2 } # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros). TEMP=`getopt -o hdp: \ - --long help,debug,port: \ + --long help,debug,port:,acct: \ -n "$0" -- "$@"` if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi @@ -54,6 +58,9 @@ do -p | --port) SSH_PORT="$2"; shift 2 ;; + --acct) + ACCT="$2"; shift 2 + ;; -d | --debug) DEBUG=1 shift @@ -105,16 +112,16 @@ function run_command() { return_var=$2 command=$3 - title "Running '${command/ARVADOS_API_TOKEN=??????????????????????????????????????????????????/ARVADOS_API_TOKEN=suppressed}' on $node" + title "Running '${command/ARVADOS_API_TOKEN=*/ARVADOS_API_TOKEN=suppressed}' on $node" TMP_FILE=`mktemp` if [[ "$DEBUG" != "0" ]]; then - ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 125" ci@$node -C "$command" | tee $TMP_FILE + ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 125" $ACCT@$node -C "$command" | tee $TMP_FILE + ECODE=$? else - ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 125" ci@$node -C "$command" > $TMP_FILE 2>&1 + ssh -t -p$SSH_PORT -o "StrictHostKeyChecking no" -o "ConnectTimeout 125" $ACCT@$node -C "$command" > $TMP_FILE 2>&1 + ECODE=$? fi - ECODE=$? - if [[ "$ECODE" != "255" && "$ECODE" != "0" ]]; then # Ssh exists 255 if the connection timed out. Just ignore that, it's possible that this node is # a shell node that is down. @@ -125,8 +132,7 @@ function run_command() { fi fi if [[ "$ECODE" == "255" ]]; then - title "Connection timed out" - ECODE=0 + title "Connection denied or timed out" fi rm -f $TMP_FILE eval "$return_var=$ECODE" @@ -153,11 +159,10 @@ fi run_command shell.$IDENTIFIER ECODE "if [[ ! -e arvados-cwl-runner-with-checksum.sh ]]; then printf \"%s\n%s\n\" '#!/bin/sh' 'exec arvados-cwl-runner --compute-checksum \"\$@\"' > arvados-cwl-runner-with-checksum.sh; chmod 755 arvados-cwl-runner-with-checksum.sh; fi" if [[ "$ECODE" != "0" ]]; then - echo "Failed to create ~ci/arvados-cwl-runner-with-checksum.sh" + echo "Failed to create ~$ACCT/arvados-cwl-runner-with-checksum.sh" exit $ECODE fi -run_command shell.$IDENTIFIER ECODE "cd common-workflow-language; git pull; ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN ./run_test.sh RUNNER=/home/ci/arvados-cwl-runner-with-checksum.sh " +run_command shell.$IDENTIFIER ECODE "cd common-workflow-language; git pull; ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN ./run_test.sh RUNNER=/home/$ACCT/arvados-cwl-runner-with-checksum.sh " exit $ECODE -