Merge "Elasticsearch: Add check to job for registering snapshot repo"
This commit is contained in:
commit
43ae215ca9
elasticsearch
@ -19,25 +19,42 @@ limitations under the License.
|
||||
|
||||
set -ex
|
||||
|
||||
function contains() {
|
||||
[[ $1 =~ (^|[[:space:]])$2($|[[:space:]]) ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
function register_snapshot_repository() {
|
||||
result=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
||||
"${ELASTICSEARCH_HOST}/_snapshot/$1" \
|
||||
-H 'Content-Type: application/json' -d'
|
||||
{
|
||||
"type": "s3",
|
||||
"settings": {
|
||||
"endpoint": "'"$RGW_HOST"'",
|
||||
"protocol": "http",
|
||||
"bucket": "'"$S3_BUCKET"'",
|
||||
"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 $1 created!";
|
||||
else
|
||||
echo "Snapshot repository $1 not created!";
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
# Get names of all current snapshot repositories
|
||||
snapshot_repos=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
||||
"${ELASTICSEARCH_HOST}"/_cat/repositories?format=json | jq -r '.[].id')
|
||||
|
||||
# Create snapshot repositories if they don't exist
|
||||
{{ range $repository := $envAll.Values.conf.elasticsearch.snapshots.repositories }}
|
||||
result=$(curl -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
||||
"${ELASTICSEARCH_HOST}/_snapshot/{{$repository.name}}" \
|
||||
-H 'Content-Type: application/json' -d'
|
||||
{
|
||||
"type": "s3",
|
||||
"settings": {
|
||||
"endpoint": "'"$RGW_HOST"'",
|
||||
"protocol": "http",
|
||||
"bucket": "'"$S3_BUCKET"'",
|
||||
"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!";
|
||||
if contains "$snapshot_repos" {{$repository.name}}; then
|
||||
echo "Snapshot repository {{$repository.name}} exists!"
|
||||
else
|
||||
echo "Snapshot repository {{$repository.name}} not created!";
|
||||
exit 1;
|
||||
register_snapshot_repository {{$repository.name}}
|
||||
fi
|
||||
{{ end }}
|
||||
|
@ -28,7 +28,7 @@ images:
|
||||
helm_tests: docker.io/openstackhelm/heat:newton
|
||||
prometheus_elasticsearch_exporter: docker.io/justwatch/elasticsearch_exporter:1.0.1
|
||||
dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1
|
||||
snapshot_repository: docker.io/openstackhelm/heat:newton
|
||||
snapshot_repository: docker.io/port/ceph-config-helper:v1.10.3
|
||||
image_repo_sync: docker.io/docker:17.07.0
|
||||
pull_policy: "IfNotPresent"
|
||||
local_registry:
|
||||
|
Loading…
x
Reference in New Issue
Block a user