From 0a42f538549a15150efec75ef181b17b5187cc45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Coutable?= <remy@rymai.me>
Date: Tue, 11 Jul 2023 14:53:43 +0200
Subject: [PATCH] ci: Fix review app deployment verification script
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Rémy Coutable <remy@rymai.me>
---
 .gitlab/ci/review-apps/main.gitlab-ci.yml | 1 -
 scripts/review_apps/review-apps.sh        | 5 +++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.gitlab/ci/review-apps/main.gitlab-ci.yml b/.gitlab/ci/review-apps/main.gitlab-ci.yml
index 065a654eab24d..f11cba97f63e7 100644
--- a/.gitlab/ci/review-apps/main.gitlab-ci.yml
+++ b/.gitlab/ci/review-apps/main.gitlab-ci.yml
@@ -49,7 +49,6 @@ review-build-cng:
     GITLAB_REPO_URL: ${CI_PROJECT_URL}
     GITLAB_IMAGE_REPOSITORY: "registry.gitlab.com/gitlab-org/build/cng-mirror"
     GITLAB_IMAGE_SUFFIX: "ee"
-    GITLAB_VERIFY_DEPLOY_TIMEOUT_MINUTES: 5
     GITLAB_HELM_CHART_REF: "75b1486a9aec212d0f49ef1251526d8e51004bbc"  # 7.0.1: https://gitlab.com/gitlab-org/charts/gitlab/-/commit/75b1486a9aec212d0f49ef1251526d8e51004bbc
   environment:
     name: review/${CI_COMMIT_REF_SLUG}${SCHEDULE_TYPE}  # No separator for SCHEDULE_TYPE so it's compatible as before and looks nice without it
diff --git a/scripts/review_apps/review-apps.sh b/scripts/review_apps/review-apps.sh
index 7ba63a4464af8..af6c2ec538384 100755
--- a/scripts/review_apps/review-apps.sh
+++ b/scripts/review_apps/review-apps.sh
@@ -395,8 +395,9 @@ function verify_deploy() {
 
   mkdir -p curl-logs/
 
-  local max_try_times=${GITLAB_VERIFY_DEPLOY_TIMEOUT_MINUTES} * 60 / 5
-  for i in {1..max_try_times}; do # try for GITLAB_VERIFY_DEPLOY_TIMEOUT_MINUTES minutes, default 5 minutes
+  # By default, try for 5 minutes, with 5 of sleep between attempts
+  local max_try_times=$((${GITLAB_VERIFY_DEPLOY_TIMEOUT_MINUTES:-5} * 60 / 5))
+  for i in {1..$max_try_times}; do
     local now=$(date '+%H:%M:%S')
     echo "[${now}] Verifying deployment at ${CI_ENVIRONMENT_URL}/users/sign_in"
     log_name="curl-logs/${now}.log"
-- 
GitLab