From 8a89840c024dc6cb4097ec37d9659598d79b5dd3 Mon Sep 17 00:00:00 2001 From: Petr OspalĂ˝ Date: Fri, 15 Nov 2019 18:00:18 +0100 Subject: Fix helm behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When 'helm serve' is not running and helm is not listening on localhost:8879 then helm starts to delete everything...instead of aborting or doing something sensible... This commit fix this misbehavior: we abort Issue-ID: OOM-2074 Change-Id: Icb4d25163012e4aedf5ec1598a4f20c738c04974 Signed-off-by: Petr OspalĂ˝ --- tools/helm-healer.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tools') diff --git a/tools/helm-healer.sh b/tools/helm-healer.sh index 0bfe013f..a6e5b398 100755 --- a/tools/helm-healer.sh +++ b/tools/helm-healer.sh @@ -134,6 +134,11 @@ error() printf "${COLOR_ON_RED}ERROR: $@ ${COLOR_OFF}\n" } +on_exit() +{ + printf "$COLOR_OFF" +} + # remove all successfully completed jobs clean_jobs() { @@ -316,6 +321,20 @@ EOF wait } +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' ) + + if [ "$_helm_serve_result" == ok ] ; then + return 0 + else + return 1 + fi +} + # arg: undeploy_component() { @@ -552,6 +571,22 @@ fi # main # +# set trap for this script cleanup +trap on_exit INT QUIT TERM EXIT + +# another sanity checks +for tool in helm kubectl curl ; do + if ! which "$tool" >/dev/null 2>&1 ; then + error "Missing '${tool}' command" + exit 1 + fi +done + +if ! is_helm_serve_running ; then + error "'helm serve' is not running (http://localhost:8879)" + exit 1 +fi + # if --delete-all is used then redeploy all components (the current namespace is deleted) if [ -n "$HELM_DELETE_ALL" ] ; then # undeploy helm release (prefix) -- cgit 1.2.3-korg