Support -j argument on run-cwl-test.sh script, to parallelize the CWL
[arvados-dev.git] / jenkins / run-deploy.sh
index 8dcf56b52a3ec520e31be5de21c2e54fbd9c8f8b..ba42008a34745c734822f7fb457c0da33cfe75fa 100755 (executable)
@@ -1,7 +1,12 @@
 #!/bin/bash
 
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 DEBUG=0
 SSH_PORT=22
+PUPPET_CONCURRENCY=5
 
 read -d] -r SCOPES <<EOF
 --scopes
@@ -34,6 +39,7 @@ function usage {
     echo >&2
     echo >&2 "$0 options:"
     echo >&2 "  -p, --port <ssh port>         SSH port to use (default 22)"
+    echo >&2 "  -c, --concurrency <max>       Maximum concurrency for puppet runs (default 5)"
     echo >&2 "  -d, --debug                   Enable debug output"
     echo >&2 "  -h, --help                    Display this help and exit"
     echo >&2
@@ -45,8 +51,8 @@ function usage {
 
 
 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
-TEMP=`getopt -o hdp: \
-    --long help,debug,port: \
+TEMP=`getopt -o hdp:c: \
+    --long help,debug,port:,concurrency: \
     -n "$0" -- "$@"`
 
 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
@@ -59,6 +65,9 @@ do
         -p | --port)
             SSH_PORT="$2"; shift 2
             ;;
+        -c | --concurrency)
+            PUPPET_CONCURRENCY="$2"; shift 2
+            ;;
         -d | --debug)
             DEBUG=1
             shift
@@ -184,11 +193,6 @@ title "Updating API server"
 SUM_ECODE=0
 run_puppet $IDENTIFIER.arvadosapi.com ECODE
 SUM_ECODE=$(($SUM_ECODE + $ECODE))
-if [ ! "$IDENTIFIER" = "c97qk" ]
-then
-  run_command $IDENTIFIER.arvadosapi.com ECODE "dpkg -L arvados-mailchimp-plugin 2>/dev/null && apt-get install arvados-mailchimp-plugin --reinstall || echo"
-  SUM_ECODE=$(($SUM_ECODE + $ECODE))
-fi
 
 if [[ "$SUM_ECODE" != "0" ]]; then
   title "ERROR: Updating API server FAILED"
@@ -208,8 +212,8 @@ if [[ "$ARVADOS_API_HOST" == "" ]] || [[ "$ARVADOS_API_TOKEN" == "" ]]; then
 fi
 
 title "Gathering list of shell and Keep nodes"
-SHELL_NODES=`ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN arv virtual_machine list |jq .items[].hostname -r`
-KEEP_NODES=`ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN arv keep_service list |jq .items[].service_host -r`
+SHELL_NODES=`ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN rvm-exec default arv virtual_machine list |jq .items[].hostname -r`
+KEEP_NODES=`ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN rvm-exec default arv keep_service list |jq .items[].service_host -r`
 
 nodes=""
 for n in workbench manage switchyard $SHELL_NODES $KEEP_NODES; do
@@ -233,7 +237,7 @@ export -f run_puppet
 export -f title
 export SSH_PORT
 export PUPPET_AGENT
-echo $nodes|xargs -d " " -n 1 -P 10 -I {} bash -c "run_puppet {}"
+echo $nodes|xargs -d " " -n 1 -P $PUPPET_CONCURRENCY -I {} bash -c "run_puppet {}"
 
 title "Locating Arvados Standard Docker images project"
 
@@ -252,7 +256,7 @@ if [[ "$DOCKER_IMAGES_PROJECT" == "" ]]; then
 fi
 
 title "Found Arvados Standard Docker Images project with uuid $DOCKER_IMAGES_PROJECT"
-GIT_COMMIT=`ssh -o "StrictHostKeyChecking no" shell.$IDENTIFIER "python -c 'import arvados_cwl ; print arvados_cwl.__version__'"`
+GIT_COMMIT=`ssh -o "StrictHostKeyChecking no" shell.$IDENTIFIER "python -c 'import arvados_cwl ; print arvados_cwl.__version__'" 2>&1 |grep -v INFO:rdflib:RDFLib`
 
 if [[ "$?" != "0" ]] || [[ "$GIT_COMMIT" == "" ]]; then
   title "ERROR: unable to get arvados/jobs Docker image git revision"
@@ -270,8 +274,15 @@ if [[ "$?" == "0" ]]; then
 else
   title "Installing latest arvados/jobs Docker image"
   ssh -o "StrictHostKeyChecking no" shell.$IDENTIFIER "ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN /usr/local/rvm/bin/rvm-exec default arv keep docker --pull --project-uuid=$DOCKER_IMAGES_PROJECT arvados/jobs $GIT_COMMIT"
+  ssh -o "StrictHostKeyChecking no" shell.$IDENTIFIER docker tag --force >/dev/null 2>&1
+  # docker 1.13 no longer supports --force. Sigh.
+  if [[ "$?" == "125" ]]; then
+    FORCE_TAG=""
+  else
+    FORCE_TAG="--force"
+  fi
   ## adding latest tag too  refs 9254
-  ssh -o "StrictHostKeyChecking no" shell.$IDENTIFIER docker tag -f arvados/jobs:$GIT_COMMIT arvados/jobs:latest
+  ssh -o "StrictHostKeyChecking no" shell.$IDENTIFIER docker tag $FORCE_TAG arvados/jobs:$GIT_COMMIT arvados/jobs:latest
   ssh -o "StrictHostKeyChecking no" shell.$IDENTIFIER "ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN arv-keepdocker --project-uuid=$DOCKER_IMAGES_PROJECT arvados/jobs latest"
   if [[ "$?" -ne 0 ]]; then
     title "'git pull' failed exiting..."