From 164e7daca32df227af86d29412f5485f4d15cfde Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Mon, 26 Aug 2024 16:06:43 +0200 Subject: [PATCH 1/2] Change the delay to 5 seconds --- scripts/start_pipelines.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/start_pipelines.sh b/scripts/start_pipelines.sh index d1f2dbd2..94c4aa0b 100755 --- a/scripts/start_pipelines.sh +++ b/scripts/start_pipelines.sh @@ -4,10 +4,11 @@ build_ns=quarkuscoffeeshop-cicd pipelines=('build-and-push-quarkuscoffeeshop-barista' 'build-and-push-quarkuscoffeeshop-counter' 'build-and-push-quarkuscoffeeshop-customerloyalty' 'build-and-push-quarkuscoffeeshop-customermocker' 'build-and-push-quarkuscoffeeshop-inventory' 'build-and-push-quarkuscoffeeshop-kitchen' 'build-and-push-quarkuscoffeeshop-web') echo "Checking for resources to be available to start pipelines" +DELAY=5 retry=0 check=1 while [ "$check" == "1" ]; do - sleep 2; + sleep ${DELAY} for p in ${pipelines[@]}; do oc get -n $build_ns pipeline $p 1>/dev/null 2>/dev/null From c7483061c3596681db4580d28c72d404fe5e1344 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Mon, 26 Aug 2024 16:14:30 +0200 Subject: [PATCH 2/2] Wait for clustertasks before checking pipelines We observed on an SNO system, that the pipelines were there but the clustertasks were not created yet, and so all the pipelineruns just failed due to missing tasks. Let's make sure we wait for clustertasks first. We wait for max an hour --- scripts/start_pipelines.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/start_pipelines.sh b/scripts/start_pipelines.sh index 94c4aa0b..6b527abf 100755 --- a/scripts/start_pipelines.sh +++ b/scripts/start_pipelines.sh @@ -3,8 +3,27 @@ build_ns=quarkuscoffeeshop-cicd pipelines=('build-and-push-quarkuscoffeeshop-barista' 'build-and-push-quarkuscoffeeshop-counter' 'build-and-push-quarkuscoffeeshop-customerloyalty' 'build-and-push-quarkuscoffeeshop-customermocker' 'build-and-push-quarkuscoffeeshop-inventory' 'build-and-push-quarkuscoffeeshop-kitchen' 'build-and-push-quarkuscoffeeshop-web') -echo "Checking for resources to be available to start pipelines" + +MAX_ATTEMPTS=720 DELAY=5 +ATTEMPT=1 + +while [ ${ATTEMPT} -le ${MAX_ATTEMPTS} ]; do + OUT=$(oc get clustertasks 2>/dev/null | wc -l) + if [ ${OUT} -gt 0 ]; then + echo "ClusterTasks found" + break + else + echo "ClusterTasks not found yet" + if [ ${ATTEMPT} -ge ${MAX_ATTEMPTS} ]; then + echo "Max attempts reached. Existing." + fi + ATTEMPT=$((ATTEMPT + 1)) + sleep ${DELAY} + fi +done + +echo "Checking for resources to be available to start pipelines" retry=0 check=1 while [ "$check" == "1" ]; do