From: Ferenc Tóth Date: Wed, 21 Aug 2019 20:50:48 +0000 (+0200) Subject: Fix ElasticSearch data rotation script X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=ef588653c443ed76d0f8f291fd6d85fe2a1bca05;p=ta%2Fcaas-install.git Fix ElasticSearch data rotation script Fix ElasticSearch data rotation script to handle indices from multiple namespaces. Signed-off-by: Ferenc Tóth Change-Id: I7da41da2c6d352ff103d43256b3fd6e0e4943517 --- diff --git a/SPECS/infra-charts.spec b/SPECS/infra-charts.spec index db86251..4fac4e4 100644 --- a/SPECS/infra-charts.spec +++ b/SPECS/infra-charts.spec @@ -15,7 +15,7 @@ %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} diff --git a/infra-charts/templates/elasticsearch-configmap.yaml b/infra-charts/templates/elasticsearch-configmap.yaml index 4e217d9..92c128c 100644 --- a/infra-charts/templates/elasticsearch-configmap.yaml +++ b/infra-charts/templates/elasticsearch-configmap.yaml @@ -129,15 +129,12 @@ data: # 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 }}