From 7be42d3cd50a82f37e2609efa9e1dc0404e8700e Mon Sep 17 00:00:00 2001 From: Steve Wilkerson Date: Wed, 12 Dec 2018 14:44:49 -0600 Subject: [PATCH] Elasticsearch: Define success criteria for adding snapshot repo This adds a simple check to the Elasticsearch snapshot repo job that will cause the job to fail if the repository isn't added successfully Change-Id: I9dca6ef545b43c52a37542319fa2f706b174c44b --- .../templates/bin/_register-repository.sh.tpl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/elasticsearch/templates/bin/_register-repository.sh.tpl b/elasticsearch/templates/bin/_register-repository.sh.tpl index 7d31119f2..983e8024d 100644 --- a/elasticsearch/templates/bin/_register-repository.sh.tpl +++ b/elasticsearch/templates/bin/_register-repository.sh.tpl @@ -20,7 +20,7 @@ limitations under the License. set -ex {{ range $repository := $envAll.Values.conf.elasticsearch.snapshots.repositories }} -curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \ +result=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \ "${ELASTICSEARCH_HOST}/_snapshot/{{$repository.name}}" \ -H 'Content-Type: application/json' -d' { @@ -32,5 +32,12 @@ curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \ "access_key": "'"$S3_ACCESS_KEY"'", "secret_key": "'"$S3_SECRET_KEY"'" } - }' + }' | python -c "import sys, json; print json.load(sys.stdin)['acknowledged']") +if [ "$result" == "True" ]; +then + echo "Snapshot repository {{$repository.name}} created!"; +else + echo "Snapshot repository {{$repository.name}} not created!"; + exit 1; +fi {{ end }}