Fix ElasticSearch data rotation script to handle indices
from multiple namespaces.
Signed-off-by: Ferenc Tóth <ferenc.2.toth@nokia.com>
Change-Id: I7da41da2c6d352ff103d43256b3fd6e0e4943517
%define COMPONENT infra-charts
%define RPM_NAME caas-%{COMPONENT}
%define RPM_MAJOR_VERSION 1.0.0
-%define RPM_MINOR_VERSION 21
+%define RPM_MINOR_VERSION 22
Name: %{RPM_NAME}
Version: %{RPM_MAJOR_VERSION}
# limitations under the License.
FS_LIMIT=80
-
declare -i pcent=100
-
-
while [ $pcent -ge $FS_LIMIT ]
do
pcent=`df --output=pcent /usr/share/elasticsearch/data | tail -n1 | tr -d '%'`
if [ $pcent -le $FS_LIMIT ]; then exit; fi
- oldest=`curl -s -XGET 'localhost:{{ .Values.elasticsearch.port }}/_cat/indices' | cut -d' ' -f3 | grep ^{{ .Values.elasticsearch.logstash_prefix }} | sort | head -n1`
+ oldest=`curl -s -XGET 'localhost:{{ .Values.elasticsearch.port }}/_cat/indices' | awk '{print $3}' | egrep '^.+-[[:digit:]]{4}\.[[:digit:]]{2}\.[[:digit:]]{2}$' | sort -t'-' -k2 | head -n1`
curl -XDELETE "localhost:{{ .Values.elasticsearch.port }}/$oldest" >/dev/null
done
{{ end }}