Fix ElasticSearch data rotation script 44/1444/2
authorFerenc Tóth <ferenc.2.toth@nokia.com>
Wed, 21 Aug 2019 20:50:48 +0000 (22:50 +0200)
committerFerenc Tóth <ferenc.2.toth@nokia.com>
Thu, 22 Aug 2019 14:24:58 +0000 (16:24 +0200)
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

SPECS/infra-charts.spec
infra-charts/templates/elasticsearch-configmap.yaml

index db86251..4fac4e4 100644 (file)
@@ -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}
index 4e217d9..92c128c 100644 (file)
@@ -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 }}