From ef588653c443ed76d0f8f291fd6d85fe2a1bca05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ferenc=20T=C3=B3th?= Date: Wed, 21 Aug 2019 22:50:48 +0200 Subject: [PATCH] Fix ElasticSearch data rotation script MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix ElasticSearch data rotation script to handle indices from multiple namespaces. Signed-off-by: Ferenc Tóth Change-Id: I7da41da2c6d352ff103d43256b3fd6e0e4943517 --- SPECS/infra-charts.spec | 2 +- infra-charts/templates/elasticsearch-configmap.yaml | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) 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 }} -- 2.16.6