From a1de5e3850c8922b856acfeebdc97ae67ca8ba3b Mon Sep 17 00:00:00 2001
From: Arie Peterson <arie@greenhost.nl>
Date: Wed, 6 Oct 2021 16:49:09 +0200
Subject: [PATCH] Check kustomization app readiness in separate jobs

---
 .gitlab-ci.yml         | 61 ++++++++++++++++++++++++++++++++++++++++++
 install/install-app.sh | 17 +-----------
 2 files changed, 62 insertions(+), 16 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index eedab54d5..379c86ca9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -182,6 +182,7 @@ stages:
   - setup-cluster
   - kustomization
   - install-apps
+  - apps-kustomizations-ready
   - certs
   - health-test
   - integration-test
@@ -432,6 +433,66 @@ enable-wordpress:
     - .enable_app_template
     - .wordpress_rules
 
+# Stage: apps-kustomizations-ready
+# ================
+#
+# Check that the kustomizations of all installed apps are ready.
+
+.app-kustomization-ready:
+  stage: apps-kustomizations-ready
+  extends:
+    - .kustomization-ready
+
+monitoring-kustomization-ready:
+  needs:
+    - job: setup-openappstack
+    - job: enable-monitoring
+  variables:
+    RESOURCE: "monitoring"
+  extends:
+    - .app-kustomization-ready
+    - .monitoring_rules
+
+nextcloud-kustomization-ready:
+  needs:
+    - job: setup-openappstack
+    - job: enable-nextcloud
+  variables:
+    RESOURCE: "nextcloud"
+  extends:
+    - .app-kustomization-ready
+    - .nextcloud_rules
+
+rocketchat-kustomization-ready:
+  needs:
+    - job: setup-openappstack
+    - job: enable-rocketchat
+  variables:
+    RESOURCE: "rocketchat"
+  extends:
+    - .app-kustomization-ready
+    - .rocketchat_rules
+
+wekan-kustomization-ready:
+  needs:
+    - job: setup-openappstack
+    - job: enable-wekan
+  variables:
+    RESOURCE: "wekan"
+  extends:
+    - .app-kustomization-ready
+    - .wekan_rules
+
+wordpress-kustomization-ready:
+  needs:
+    - job: setup-openappstack
+    - job: enable-wordpress
+  variables:
+    RESOURCE: "wordpress"
+  extends:
+    - .app-kustomization-ready
+    - .wordpress_rules
+
 # Stage: certs
 # ================
 #
diff --git a/install/install-app.sh b/install/install-app.sh
index 291d29c33..b7b2000ec 100755
--- a/install/install-app.sh
+++ b/install/install-app.sh
@@ -11,18 +11,6 @@ app=$1
 # generate them and add them to the cluster.
 python "$(dirname "$0")/generate_secrets.py" "$app"
 
-case "$app" in
-  monitoring)
-    namespace="oas"
-    ;;
-  velero)
-    namespace="velero"
-    ;;
-  *)
-    namespace="oas-apps"
-    ;;
-esac
-
 # This kustomization's only purpose is to add the kustomization that is in the
 # flux2/cluster/optional/$app folder. After this kustomization is applied
 # an `add-$app` kustomization will be present on the cluster, as well as a
@@ -31,7 +19,4 @@ flux create kustomization "add-${app}" \
   --source=GitRepository/openappstack \
   --path="./flux2/cluster/optional/${app}" \
   --prune=true \
-  --interval=1h \
-  --health-check="HelmRelease/${app}.${namespace}" \
-  --health-check-timeout=20m \
-  --timeout=20m
+  --interval=1h
-- 
GitLab