aboutsummaryrefslogtreecommitdiffstats
path: root/dbc-client/misc
diff options
context:
space:
mode:
authordglFromAtt <dgl@research.att.com>2019-03-14 20:30:20 +0000
committerdglFromAtt <dgl@research.att.com>2019-03-14 20:32:59 +0000
commit8d21e71c13ab39ec01070fedaa298ff72e62da58 (patch)
treef8968fb243939d6165ea3562d21f1de0b26573fa /dbc-client/misc
parentaa3cc0e7cd53265e8c82b56caf2f409ed5612e80 (diff)
Added k8s-style retry to dmaap prov
Change-Id: I96fa44824c49a98dc621afe86f4796eaef0c596e Signed-off-by: dglFromAtt <dgl@research.att.com> Issue-ID: DMAAP-1087 Signed-off-by: dglFromAtt <dgl@research.att.com>
Diffstat (limited to 'dbc-client/misc')
-rw-r--r--dbc-client/misc/dbc-client33
1 files changed, 28 insertions, 5 deletions
diff --git a/dbc-client/misc/dbc-client b/dbc-client/misc/dbc-client
index a812460..cf6c230 100644
--- a/dbc-client/misc/dbc-client
+++ b/dbc-client/misc/dbc-client
@@ -24,7 +24,7 @@
umask 0022
TZ=GMT0
COMPONENT=dbc-client
-APP_ROOT=/opt/app/$COMPONENT
+APP_ROOT=${APP_ROOT:-/opt/app/$COMPONENT}
USER=root
export TZ
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
@@ -32,6 +32,9 @@ export PATH
CONFIGMAP_ROOT=${CONFIGMAP_ROOT:-/opt/app/config}
CONTAINER_CONFIG=$CONFIGMAP_ROOT/conf/dbc-client.env
REQUESTID=${REQUESTID:-dbc-client}
+DBC=${DBC:-dmaap-bc}
+PROTO=${PROTO:-http}
+PORT=${PORT:-8080}
@@ -82,14 +85,35 @@ init() {
fi
#loop on get /dmaap until we get a good response to indicate other provisioning can continue
- rc=999
+ rc=${RESP:-999}
while [ $rc != "200" ]
do
sleep 10
- rc=`curl -s -o /dev/null -I -w "%{http_code}" -X GET -H "X-ECOMP-RequestID: $REQUESTID" -H "Content-Type: application/json" http://dmaap-bc:8080/webapi/dmaap`
+ rc=`curl -s -o /dev/null -I -w "%{http_code}" -X GET -H "X-ECOMP-RequestID: $REQUESTID" -H "Content-Type: application/json" ${PROTO}://${DBC}:${PORT}/webapi/dmaap`
echo "get dmaap response=${rc}"
done
}
+dopost() {
+ RETRY_TIME=60
+
+ loop=true
+
+ while [ $loop ]
+ do
+ rc=`curl -v -X POST -w "%{http_code}" -H "X-ECOMP-RequestID: $REQUESTID" -H "Content-Type: application/json" -d @${1} ${PROTO}://${DBC}:${PORT}/webapi/${2}`
+ case $rc in
+ 200 | 201 | 409 )
+ echo "response=$rc"
+ loop=false
+ ;;
+ * )
+ echo "`date`: http response=$rc. Will retry after $RETRY_TIME seconds"
+ sleep $RETRY_TIME
+ ;;
+ esac
+ done
+
+}
doprov() {
cd $CONFIGMAP_ROOT
@@ -102,8 +126,7 @@ doprov() {
for j in `ls ${uri}/*.json`
do
echo "POST $j to $uri"
- rc=`curl -v -X POST -w "%{http_code}" -H "X-ECOMP-RequestID: $REQUESTID" -H "Content-Type: application/json" -d @${j} http://dmaap-bc:8080/webapi/${uri}`
- echo "response=$rc"
+ dopost $j $uri
done
fi
done