From 7f7ddd1ab0364928ff91de9d433b338cafdb7f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Wed, 5 Sep 2018 14:38:33 +0200 Subject: [PATCH] better health check in dashboard import init container if kibana is ready (#7526) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Bauer --- stable/kibana/Chart.yaml | 2 +- .../templates/configmap-dashboardimport.yaml | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/stable/kibana/Chart.yaml b/stable/kibana/Chart.yaml index cd279e7d72..87131126c4 100644 --- a/stable/kibana/Chart.yaml +++ b/stable/kibana/Chart.yaml @@ -1,5 +1,5 @@ name: kibana -version: 0.13.0 +version: 0.13.1 appVersion: 6.4.0 description: Kibana is an open source data visualization plugin for Elasticsearch icon: https://raw.githubusercontent.com/elastic/kibana/master/src/ui/public/icons/kibana-color.svg diff --git a/stable/kibana/templates/configmap-dashboardimport.yaml b/stable/kibana/templates/configmap-dashboardimport.yaml index c81d8bef52..6ba7644750 100644 --- a/stable/kibana/templates/configmap-dashboardimport.yaml +++ b/stable/kibana/templates/configmap-dashboardimport.yaml @@ -17,26 +17,27 @@ data: cd /kibanadashboards - echo "starting kibana..." + echo "Starting Kibana..." /usr/local/bin/kibana-docker $@ & - echo "waiting up to {{ .Values.readinessProbe.initialDelaySeconds }} seconds for kibana to come up..." + echo "Waiting up to 60 seconds for Kibana to get in green overall state..." - for i in {1..{{ .Values.readinessProbe.initialDelaySeconds }}}; do - curl -Is localhost:5601/api/status | grep "HTTP.*200" > /dev/null && break || sleep 1 + for i in {1..60}; do + curl -s localhost:5601/api/status | python -c 'import sys, json; print json.load(sys.stdin)["status"]["overall"]["state"]' 2> /dev/null | grep green > /dev/null && break || sleep 1 done for DASHBOARD_FILE in *; do - echo -e "\nimporting ${DASHBOARD_FILE}..." + echo -e "Importing ${DASHBOARD_FILE} dashboard..." - curl {{ if .Values.dashboardImport.xpackauth.enabled }}--user {{ .Values.dashboardImport.xpackauth.username }}:{{ .Values.dashboardImport.xpackauth.password }}{{ end }} -s --connect-timeout 60 --max-time 60 -XPOST localhost:5601/api/kibana/dashboards/import?force=true -H 'kbn-xsrf:true' -H 'Content-type:application/json' -d @./${DASHBOARD_FILE} + curl -v {{ if .Values.dashboardImport.xpackauth.enabled }}--user {{ .Values.dashboardImport.xpackauth.username }}:{{ .Values.dashboardImport.xpackauth.password }}{{ end }} -s --connect-timeout 60 --max-time 60 -XPOST localhost:5601/api/kibana/dashboards/import?force=true -H 'kbn-xsrf:true' -H 'Content-type:application/json' -d @./${DASHBOARD_FILE} if [ "$?" != "0" ]; then - echo -e "\nimport of ${DASHBOARD_FILE} failed... restarting container..." + echo -e "\nImport of ${DASHBOARD_FILE} dashboard failed... restarting container in 5 seconds..." + sleep 5 exit 1 else - echo -e "\nimport of ${DASHBOARD_FILE} finished :-)" + echo -e "\nImport of ${DASHBOARD_FILE} dashboard finished :-)" fi done