Skip to content

Commit

Permalink
Improvements to wait_for_pods function
Browse files Browse the repository at this point in the history
Signed-off-by: hbelmiro <[email protected]>
  • Loading branch information
hbelmiro committed Sep 2, 2024
1 parent 0d098db commit 3df7182
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/sdk-execution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
pull_request:
paths:
- '.github/workflows/sdk-execution.yml'
- 'scripts/deploy/github/**'
- 'sdk/python/**'
- 'api/v2alpha1/**'

Expand Down
16 changes: 5 additions & 11 deletions scripts/deploy/github/helper-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}\"."

Expand Down

0 comments on commit 3df7182

Please sign in to comment.