summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Ospalý <p.ospaly@partner.samsung.com>2019-11-15 18:00:18 +0100
committerPetr Ospalý <p.ospaly@partner.samsung.com>2019-11-15 18:55:12 +0100
commit8a89840c024dc6cb4097ec37d9659598d79b5dd3 (patch)
treeb7c9dc8bc8656de767110e0ead6d3aec05f3e7e3
parent7e1861c6b8ba6a1de63a876248bbf4d02c9538ff (diff)
Fix helm behavior
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ý <p.ospaly@partner.samsung.com>
-rwxr-xr-xtools/helm-healer.sh35
1 files changed, 35 insertions, 0 deletions
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: <release name>
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)