From 95477ae0c6dce1c218d7883bf3221f36c6f67539 Mon Sep 17 00:00:00 2001 From: Branden Rolston Date: Wed, 22 Jan 2020 23:12:02 -0800 Subject: [PATCH] Retry failed attempts to set grafana home dashboard The job that sets Grafana's home dashboard may run before Grafana's API is ready. --- staging/prometheus-operator/Chart.yaml | 2 +- .../templates/mesosphere-hooks/post-install-hooks.yaml | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/staging/prometheus-operator/Chart.yaml b/staging/prometheus-operator/Chart.yaml index 2c16032dc..896498e13 100644 --- a/staging/prometheus-operator/Chart.yaml +++ b/staging/prometheus-operator/Chart.yaml @@ -12,7 +12,7 @@ sources: - https://github.com/coreos/kube-prometheus - https://github.com/coreos/prometheus-operator - https://coreos.com/operators/prometheus -version: 8.3.8 +version: 8.3.9 appVersion: 0.34.0 tillerVersion: ">=2.12.0" home: https://github.com/coreos/prometheus-operator diff --git a/staging/prometheus-operator/templates/mesosphere-hooks/post-install-hooks.yaml b/staging/prometheus-operator/templates/mesosphere-hooks/post-install-hooks.yaml index c93e8cf76..3df07a7a3 100644 --- a/staging/prometheus-operator/templates/mesosphere-hooks/post-install-hooks.yaml +++ b/staging/prometheus-operator/templates/mesosphere-hooks/post-install-hooks.yaml @@ -40,7 +40,11 @@ metadata: data: run.sh: |- #!/bin/bash - DASHBOARD_ID=$(curl --fail -H "X-Forwarded-User: $X_FORWARDED_USER" {{ .Values.mesosphereResources.hooks.grafana.serviceURL }}/api/search/?query=Kubernetes+%2F+Compute+Resources+%2F+Cluster | jq '.[0].id') - echo $DASHBOARD_ID - curl -X PUT -v --fail -H "Content-Type: application/json" -H "X-Forwarded-User: $X_FORWARDED_USER" -d '{"theme":"","homeDashboardId":'"$DASHBOARD_ID"',"timezone":""}' {{ .Values.mesosphereResources.hooks.grafana.serviceURL }}/api/org/preferences + set -o nounset + set -o errexit + set -o pipefail + CURL="curl --verbose --fail --max-time 60 --retry 10 --retry-connrefused" + DASHBOARD_ID=$($CURL -H "X-Forwarded-User: $X_FORWARDED_USER" {{ .Values.mesosphereResources.hooks.grafana.serviceURL }}/api/search/?query=Kubernetes+%2F+Compute+Resources+%2F+Cluster | jq '.[0].id') + echo "setting home dashboard to ID" $DASHBOARD_ID + $CURL -X PUT -H "Content-Type: application/json" -H "X-Forwarded-User: $X_FORWARDED_USER" -d '{"theme":"","homeDashboardId":'"$DASHBOARD_ID"',"timezone":""}' {{ .Values.mesosphereResources.hooks.grafana.serviceURL }}/api/org/preferences