reindex.sh: fix paths for cloning

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-05-27 11:53:19 +02:00
parent 4dcc207cc4
commit 55ba86a864
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 8 additions and 7 deletions

View File

@ -7,9 +7,9 @@ function queryAPI() {
method=$1
path=$2
data=$3
cmd="curl -s -X${method} http://localhost:9200/${path}"
cmd="curl -f -s -X${method} http://localhost:9200/${path}"
if [[ -n "${data}" ]]; then
cmd+=" -f -H 'content-type:application/json' -d '${data}'"
cmd+=" -H 'content-type:application/json' -d '${data}'"
fi
eval "${cmd}"
}
@ -23,15 +23,15 @@ function reindex() {
}
function clone() {
queryAPI POST "/${1}/_clone/${2}" '{"settings":{"index.blocks.write":null}}'
queryAPI POST "${1}/_clone/${2}" '{"settings":{"index.blocks.write":null}}'
}
function read_only() {
queryAPI PUT "/${1}/_settings" '{"settings":{"index.blocks.write":"true"}}'
queryAPI PUT "${1}/_settings" '{"settings":{"index.blocks.write":"true"}}'
}
function wait_green() {
queryAPI GET "/_cluster/health/${1}?wait_for_status=green&timeout=9000s"
queryAPI GET "_cluster/health/${1}?wait_for_status=green&timeout=9000s"
}
function delete() {
@ -71,8 +71,9 @@ echo "! Deleting: ${old}"
delete "${old}" > /dev/null
echo "+ Cloning: ${new} -> ${old}"
read_only "${new}" > /dev/null
clone "${new}" "${old}" > /dev/null
wait_green "${old}"
clone "${new}" "${old}"
echo "+ Waiting: ${old}"
wait_green "${old}" > /dev/null
echo "? $(printf '%-21s' ${old}) - Count: $(docs_count ${old})"
echo "? $(printf '%-21s' ${old}) - Size: $(size_in_bytes ${old}) MB"
echo "! Deleting: ${new}"