From 5320343587d30a6170d6c7ddefb3588e8a96f67e Mon Sep 17 00:00:00 2001 From: Alexandre Lamarre Date: Thu, 25 Apr 2024 11:54:56 -0400 Subject: [PATCH] add timeout to setup-cluster Signed-off-by: Alexandre Lamarre --- .github/workflows/scripts/setup-cluster.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/scripts/setup-cluster.sh b/.github/workflows/scripts/setup-cluster.sh index fa02f717..31c0a0fd 100755 --- a/.github/workflows/scripts/setup-cluster.sh +++ b/.github/workflows/scripts/setup-cluster.sh @@ -16,14 +16,29 @@ fi # waits until all nodes are ready wait_for_nodes(){ + timeout=120 + start_time=$(date +%s) echo "wait until all agents are ready" while : do + current_time=$(date +%s) + elapsed_time=$((current_time - start_time)) + if [ $elapsed_time -ge $timeout ]; then + echo "Timeout reached, exiting..." + exit 1 + fi + readyNodes=1 statusList=$(kubectl get nodes --no-headers | awk '{ print $2}') # shellcheck disable=SC2162 while read status do + current_time=$(date +%s) + elapsed_time=$((current_time - start_time)) + if [ $elapsed_time -ge $timeout ]; then + echo "Timeout reached, exiting..." + exit 1 + fi if [ "$status" == "NotReady" ] || [ "$status" == "" ] then readyNodes=0