Skip to content

Commit

Permalink
check for index existence before attemping rollover
Browse files Browse the repository at this point in the history
Signed-off-by: reyesj2 <[email protected]>
  • Loading branch information
reyesj2 committed Jan 17, 2025
1 parent 9032d7d commit 01a2e4c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions salt/manager/tools/sbin/soup
Original file line number Diff line number Diff line change
Expand Up @@ -814,12 +814,16 @@ rollover_index() {
idx=$1
exists=$(curl -K /opt/so/conf/elasticsearch/curl.config -s -o /dev/null -w "%{http_code}" -k -L -H "Content-Type: application/json" "https://localhost:9200/$idx")

rollover=$(curl -K /opt/so/conf/elasticsearch/curl.config -s -o /dev/null -w "%{http_code}" -k -L -H "Content-Type: application/json" "https://localhost:9200/$idx/_rollover" -XPOST)
if [[ $exists -eq 200 ]]; then
rollover=$(curl -K /opt/so/conf/elasticsearch/curl.config -s -o /dev/null -w "%{http_code}" -k -L -H "Content-Type: application/json" "https://localhost:9200/$idx/_rollover" -XPOST)

if [[ $rollover -eq 200 ]]; then
echo "Successfully triggered rollover for $idx..."
if [[ $rollover -eq 200 ]]; then
echo "Successfully triggered rollover for $idx..."
else
echo "Could not trigger rollover for $idx..."
fi
else
echo "Could not trigger rollover for $idx..."
echo "Could not find index $idx..."
fi
}

Expand Down

0 comments on commit 01a2e4c

Please sign in to comment.