diff options
author | Lusheng Ji <lji@research.att.com> | 2018-04-05 12:02:52 -0400 |
---|---|---|
committer | Lusheng Ji <lji@research.att.com> | 2018-04-05 12:03:01 -0400 |
commit | ac864ceb9f1eeef6057d105e7a670ad064701750 (patch) | |
tree | 6905b70449948173470e7c7db2b671c448f21050 /tca-cdap-container | |
parent | 3044455f4dc7959d8daa5410e1d6acb09ae24439 (diff) |
Fix poll policy error
Issue-ID: DCAEGEN2-206
Change-Id: I728d00bd74a6cdc5b1aca520efe77f686ef9aae0
Signed-off-by: Lusheng Ji <lji@research.att.com>
Diffstat (limited to 'tca-cdap-container')
-rwxr-xr-x | tca-cdap-container/restart.sh | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/tca-cdap-container/restart.sh b/tca-cdap-container/restart.sh index bc15cac..95a41d2 100755 --- a/tca-cdap-container/restart.sh +++ b/tca-cdap-container/restart.sh @@ -147,9 +147,24 @@ function tca_poll_policy { URL2="$URL1:preferences" echo "tca_poll_policy: Retrieving configuration file at ${URL1}" - curl -s "$URL1" | jq . --sort-keys > "${TCA_CONF_TEMP}" - echo "Retrieving preferences file at ${URL1}" - curl -s "$URL2" | jq . --sort-keys > "${TCA_PREF_TEMP}" + HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" "$URL1") + HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g') + HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') + if [ "$HTTP_STATUS" != "200" ]; then + echo "receiving $HTTP_RESPONSE from CBS" + return + fi + echo $HTTP_BODY | jq . --sort-keys > "${TCA_CONF_TEMP}" + + echo "tca_poll_policy: Retrieving preferences file at ${URL1}" + HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" "$URL2") + HTTP_BODY=$(echo $HTTP_RESPONSE | sed -e 's/HTTPSTATUS\:.*//g') + HTTP_STATUS=$(echo $HTTP_RESPONSE | tr -d '\n' | sed -e 's/.*HTTPSTATUS://') + if [ "$HTTP_STATUS" != "200" ]; then + echo "receiving $HTTP_RESPONSE from CBS" + return + fi + echo $HTTP_BODY | jq . --sort-keys > "${TCA_PREF_TEMP}" if [ ! -e "${TCA_CONF_TEMP}" ] || [ "$(ls -sh ${TCA_CONF_TEMP} |cut -f1 -d' ' |sed -e 's/[^0-9]//g')" -lt "1" ]; then echo "Fail to receive configuration" |