Skip to content

Commit 3df7182

Browse files
committed
Improvements to wait_for_pods function
Signed-off-by: hbelmiro <helber.belmiro@gmail.com>
1 parent 0d098db commit 3df7182

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

.github/workflows/sdk-execution.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
paths:
99
- '.github/workflows/sdk-execution.yml'
10+
- 'scripts/deploy/github/**'
1011
- 'sdk/python/**'
1112
- 'api/v2alpha1/**'
1213

scripts/deploy/github/helper-functions.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,14 @@ wait_for_pods () {
7474
local statuses
7575
local num_pods
7676
local num_running
77-
pods=$(kubectl get pod -n "$namespace")
78-
# echo "$pods"
79-
# kubectl get pvc -n "$namespace"
77+
pods=$(kubectl get pod -n "$namespace" --no-headers 2>/dev/null)
8078

81-
if [[ -z $pods ]]
82-
then
83-
echo "no pod is up yet"
79+
if [[ -z $pods ]]; then
80+
echo "No pods found or error retrieving pods."
8481
else
85-
# Using quotations around variables to keep column format in echo
86-
# Remove 1st line (header line) -> trim whitespace -> cut statuses column (3rd column)
87-
# Might be overkill to parse down to specific columns :).
88-
statuses=$(echo "$pods" | tail -n +2 | tr -s ' ' | cut -d ' ' -f 3)
82+
statuses=$(echo "$pods" | awk '{print $3}')
8983
num_pods=$(echo "$statuses" | wc -l | xargs)
90-
num_running=$(echo "$statuses" | grep -ow "Running\|Completed" | wc -l | xargs)
84+
num_running=$(echo "$statuses" | grep -cE 'Running|Completed')
9185

9286
local msg="${num_running}/${num_pods} pods running in \"${namespace}\"."
9387

0 commit comments

Comments
 (0)