Elasticsearch: Improve logging in cluster wait
The cluster wait function can sometimes receive an invalid response, and this would "pass" the status check condition. This change prints the response to make it more clear what occured, and changes the condition to explicitly wait for a "yellow" or "green" status. Change-Id: Ifd1267a5fa19acbc6bc8bba65b1ba41409a584a3
This commit is contained in:
parent
84426374b6
commit
083c9498c6
@ -14,13 +14,15 @@ limitations under the License.
|
||||
*/}}
|
||||
|
||||
function check_cluster_health() {
|
||||
STATUS=$(curl -s -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
||||
"${ELASTICSEARCH_HOST}/_cat/health?format=json&pretty" | jq -r .[].status)
|
||||
RESPONSE=$(curl -s -K- <<< "--user ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD}" \
|
||||
"${ELASTICSEARCH_HOST}/_cat/health?format=json&pretty" )
|
||||
echo "Response: $RESPONSE"
|
||||
STATUS=$(echo $RESPONSE | jq -r .[].status)
|
||||
echo "Status: $STATUS"
|
||||
}
|
||||
|
||||
check_cluster_health
|
||||
while [[ $STATUS == "red" ]]; do
|
||||
while [[ $STATUS != "yellow" ]] && [[ $STATUS != "green" ]]; do
|
||||
echo "Waiting for cluster to become ready."
|
||||
sleep 30
|
||||
check_cluster_health
|
||||
|
Loading…
Reference in New Issue
Block a user