Skip to content

Commit

Permalink
move variable to right scope
Browse files Browse the repository at this point in the history
  • Loading branch information
makelicious committed Aug 14, 2024
1 parent c750570 commit 1df66be
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions infrastructure/elasticsearch/setup-elastalert-indices.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,19 @@ indices='elastalert_status,elastalert_status_error,elastalert_status_past,elasta

bulk_delete_status_code=$($docker_command --connect-timeout 60 -u elastic:$ELASTICSEARCH_SUPERUSER_PASSWORD -o /dev/null -w '%{http_code}' "http://elasticsearch:9200/${indices}" -X DELETE)

<<<<<<< HEAD
if [ "$delete_status_code" -ne 200 ]; then
echo "Could not delete indices. API returned status code: $delete_status_code"
exit 1
fi

echo 'Scaling up Elastalert'
docker service scale opencrvs_elastalert=1

=======
if [ "$bulk_delete_status_code" -ne 200 ]; then
echo "Could not delete indices. API returned status code: $bulk_delete_status_code"
fi


non_404_error_when_deleting_one_by_one=0

if [ "$bulk_delete_status_code" -eq 404 ]; then
echo "Some of the indices do not exist. Attempting to delete them one by one."

# Convert the comma-separated indices into an array
IFS=',' read -r -a indices_array <<< "$indices"



non_404_error_when_deleting_one_by_one=0

for index in "${indices_array[@]}"; do
echo "Deleting index: $index"
individual_delete_status_code=$($docker_command --connect-timeout 60 -u elastic:$ELASTICSEARCH_SUPERUSER_PASSWORD -o /dev/null -w '%{http_code}' "http://elasticsearch:9200/${index}" -X DELETE)
Expand All @@ -81,5 +70,4 @@ if [ "$non_404_error_when_deleting_one_by_one" -eq 0 ] && { [ "$bulk_delete_stat
exit 0
fi

exit 1

exit 1

0 comments on commit 1df66be

Please sign in to comment.