[ARVADOS-DEV] created: 9d43ab88e37dcdb5053ce552a398a34ba9c9224f
git at public.curoverse.com
git at public.curoverse.com
Wed Oct 14 18:19:00 EDT 2015
at 9d43ab88e37dcdb5053ce552a398a34ba9c9224f (commit)
commit 9d43ab88e37dcdb5053ce552a398a34ba9c9224f
Author: Brett Smith <brett at curoverse.com>
Date: Wed Oct 14 18:18:58 2015 -0400
7341: run-deploy.sh retries failed Puppet agent runs.
It simply keeps retrying any failure until ten minutes have passed,
per Nico's suggestion in the comments.
Bonus bugfix: make sure run_puppet's ECODE variable gets set to the
exit status of Puppet (or the wrapper script), and not tee.
diff --git a/jenkins/run-deploy.sh b/jenkins/run-deploy.sh
index 4953659..59c7ae4 100755
--- a/jenkins/run-deploy.sh
+++ b/jenkins/run-deploy.sh
@@ -64,6 +64,21 @@ EXITCODE=0
COLUMNS=80
+PUPPET_AGENT='
+alias now="date +%s"
+let endtime="$(now) + 600"
+while [ "$endtime" -gt "$(now)" ]; do
+ puppet agent --test --detailed-exitcodes
+ agent_exitcode=$?
+ if [ 0 = "$agent_exitcode" ] || [ 2 = "$agent_exitcode" ]; then
+ exit 0
+ else
+ sleep 10s
+ fi
+done
+exit ${agent_exitcode:-99}
+'
+
title () {
date=`date +'%Y-%m-%d %H:%M:%S'`
printf "$date $1\n"
@@ -76,12 +91,12 @@ function run_puppet() {
title "Running puppet on $node"
TMP_FILE=`mktemp`
if [[ "$DEBUG" != "0" ]]; then
- ssh -t -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C "/usr/bin/puppet agent -t" | tee $TMP_FILE
+ ssh -t -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C bash -c "'$PUPPET_AGENT'" | tee $TMP_FILE
else
- ssh -t -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C "/usr/bin/puppet agent -t" > $TMP_FILE 2>&1
+ ssh -t -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C bash -c "'$PUPPET_AGENT'" > $TMP_FILE 2>&1
fi
- ECODE=$?
+ ECODE=${PIPESTATUS[0]}
RESULT=$(cat $TMP_FILE)
if [[ "$ECODE" != "255" && ! ("$RESULT" =~ 'already in progress') && "$ECODE" != "2" && "$ECODE" != "0" ]]; then
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list