From bafdccabc9de867eabf732228fc7bc1e1d98e412 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Mon, 8 Mar 2021 13:40:30 +0100 Subject: Support Helm v3 in helm-healer script Change-Id: I314b37c587c76038b1694eef7d52078f2af09a1d Issue-ID: OOM-2665 Signed-off-by: Bartek Grzybowski --- tools/helm-healer.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/helm-healer.sh b/tools/helm-healer.sh index 92ddbdb7..47479a9b 100755 --- a/tools/helm-healer.sh +++ b/tools/helm-healer.sh @@ -190,7 +190,12 @@ get_labels() helm_undeploy() { msg "Undeploy helm release name: ${1}" - helm undeploy ${1} --purge + # Helm v3 does not support "--purge" flag since it's a default behavior for v3 + if [[ $(helm version --template "{{.Version}}") =~ ^v3 ]];then + helm undeploy ${1} + else + helm undeploy ${1} --purge + fi sleep 15s } @@ -349,11 +354,9 @@ docker_cleanup() is_helm_serve_running() { # healthy result: HTTP/1.1 200 OK - _helm_serve_result=$(\ - curl --head --silent --connect-timeout 3 http://127.0.0.1:8879 | \ - head -n 1 | cut -d" " -f 3 | tr '[:upper:]' '[:lower:]' | tr -d '\r' ) + _helm_serve_result=$(curl -w %{http_code} --silent --connect-timeout 3 http://127.0.0.1:8879/ -o /dev/null) - if [ "$_helm_serve_result" == ok ] ; then + if [ "$_helm_serve_result" == "200" ] ; then return 0 else return 1 @@ -620,6 +623,10 @@ if [ -n "$arg_cleanonly" ] ; then HELM_SKIP_DEPLOY=yes fi +# If running with helm v3 a time unit has to be appended to HELM_TIMEOUT +if [[ $(helm version --template "{{.Version}}") =~ ^v3 ]];then + HELM_TIMEOUT="${HELM_TIMEOUT}s" +fi # # main -- cgit 1.2.3-korg