From 3df718221b341861e35bf6c6c4d2cd8ea01d6c99 Mon Sep 17 00:00:00 2001 From: hbelmiro Date: Mon, 2 Sep 2024 15:52:22 -0300 Subject: [PATCH] Improvements to wait_for_pods function Signed-off-by: hbelmiro --- .github/workflows/sdk-execution.yml | 1 + scripts/deploy/github/helper-functions.sh | 16 +++++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/sdk-execution.yml b/.github/workflows/sdk-execution.yml index 22f605fca9f6..135296844c81 100644 --- a/.github/workflows/sdk-execution.yml +++ b/.github/workflows/sdk-execution.yml @@ -7,6 +7,7 @@ on: pull_request: paths: - '.github/workflows/sdk-execution.yml' + - 'scripts/deploy/github/**' - 'sdk/python/**' - 'api/v2alpha1/**' diff --git a/scripts/deploy/github/helper-functions.sh b/scripts/deploy/github/helper-functions.sh index 8c42a923f460..7017d5c8b1d6 100644 --- a/scripts/deploy/github/helper-functions.sh +++ b/scripts/deploy/github/helper-functions.sh @@ -74,20 +74,14 @@ wait_for_pods () { local statuses local num_pods local num_running - pods=$(kubectl get pod -n "$namespace") - # echo "$pods" - # kubectl get pvc -n "$namespace" + pods=$(kubectl get pod -n "$namespace" --no-headers 2>/dev/null) - if [[ -z $pods ]] - then - echo "no pod is up yet" + if [[ -z $pods ]]; then + echo "No pods found or error retrieving pods." else - # Using quotations around variables to keep column format in echo - # Remove 1st line (header line) -> trim whitespace -> cut statuses column (3rd column) - # Might be overkill to parse down to specific columns :). - statuses=$(echo "$pods" | tail -n +2 | tr -s ' ' | cut -d ' ' -f 3) + statuses=$(echo "$pods" | awk '{print $3}') num_pods=$(echo "$statuses" | wc -l | xargs) - num_running=$(echo "$statuses" | grep -ow "Running\|Completed" | wc -l | xargs) + num_running=$(echo "$statuses" | grep -cE 'Running|Completed') local msg="${num_running}/${num_pods} pods running in \"${namespace}\"."