From 2149ecbfd43f0a4e1b0ec00f1820ee38b5d6bd1e Mon Sep 17 00:00:00 2001 From: Simon Emms Date: Thu, 21 Apr 2022 20:16:36 +0000 Subject: [PATCH] [kots]: add install delete job to remove existing stalled jobs --- .../kots/manifests/gitpod-installer-job.yaml | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/install/kots/manifests/gitpod-installer-job.yaml b/install/kots/manifests/gitpod-installer-job.yaml index 0332c50ac4ea21..dcc9e159326ad5 100644 --- a/install/kots/manifests/gitpod-installer-job.yaml +++ b/install/kots/manifests/gitpod-installer-job.yaml @@ -7,7 +7,8 @@ apiVersion: batch/v1 kind: Job metadata: - name: installer + # Appending cursor allows us to replace with new versions + name: installer-{{repl Cursor }} labels: app: gitpod component: gitpod-installer @@ -50,6 +51,23 @@ spec: - | set -e + echo "Gitpod: Checking for any in-progress installations" + + if [ "$(helm status -n {{repl Namespace }} gitpod -o json | jq '.info.status == "deployed"')" = "false" ]; + then + echo "Gitpod: Deployment in-progress - clearing" + + VERSION="$(helm status -n {{repl Namespace }} gitpod -o json | jq '.version')" + if [ "${VERSION}" -le 1 ]; + then + echo "Gitpod: Uninstall application" + helm uninstall -n {{repl Namespace }} gitpod --wait || true + else + echo "Gitpod: Rolling back application" + helm rollback -n {{repl Namespace }} gitpod --wait || true + fi + fi + echo "Gitpod: Generate the base Installer config" /app/installer init > "${CONFIG_FILE}" @@ -215,6 +233,9 @@ spec: echo "Gitpod: Restarting installation status job" kubectl delete pod -n {{repl Namespace }} -l component=gitpod-installer-status || true + echo "Gitpod: Killing any outstanding installation jobs" + kubectl delete jobs.batch -n {{repl Namespace }} -l component=gitpod-installer || true + echo "Gitpod: Installer job finished - goodbye" volumes: - name: config-patch