From 1d28f73687d5e477b4bbba206205651499242e59 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 15 Apr 2014 15:58:41 -0400 Subject: [PATCH] Include the actuall callback retry script --- tools/scripts/callback_retry.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tools/scripts/callback_retry.sh diff --git a/tools/scripts/callback_retry.sh b/tools/scripts/callback_retry.sh new file mode 100644 index 0000000000..0a0208e8be --- /dev/null +++ b/tools/scripts/callback_retry.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +usage() { + echo -e "Retry callback attempt if we don't receive a 202 response from the Tower API\n" + echo "Usage: $0 [:server port] " + exit 1 +} + +[ $# -lt 3 ] && usage + +retry_attempts=5 +attempt=0 +while [[ $attempt < $retry_attempts ]] +do + status_code=`curl -s -i --data "host_config_key=$2" http://$1/api/v1/job_templates/$3/callback/ | head -n 1 | awk '{print $2}'` + if [[ $status_code == 202 ]] + then + exit 0 + fi + attempt=$(( attempt + 1 )) + echo "${status_code} received... retrying." + sleep 5 +done +exit 1