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 <helber.belmiro@gmail.com>
  • Loading branch information
hbelmiro committed Sep 2, 2024
1 parent 76a7df9 commit d2a30f3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions scripts/deploy/github/helper-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,22 @@ wait_for_pods () {
while [[ $i -lt $max_retries ]]
do
local pods
local statuses
local ready_pods
local num_pods
local num_running
local num_ready

pods=$(kubectl get pod -n "$namespace" --no-headers 2>/dev/null)

if [[ -z $pods ]]; then
echo "No pods found or error retrieving pods."
else
statuses=$(echo "$pods" | awk '{print $3}')
num_pods=$(echo "$statuses" | wc -l | xargs)
num_running=$(echo "$statuses" | grep -cE 'Running|Completed')
ready_pods=$(echo "$pods" | awk '$2 == $3 {print $0}')
num_pods=$(echo "$pods" | wc -l | xargs)
num_ready=$(echo "$ready_pods" | wc -l | xargs)

local msg="${num_running}/${num_pods} pods running in \"${namespace}\"."
local msg="${num_ready}/${num_pods} pods are ready in \"${namespace}\"."

if [[ $num_running -ne $num_pods ]]
then
if [[ $num_ready -ne $num_pods ]]; then
# for debugging
# kubectl get pod -n "$namespace" | grep '0/1' | awk '{print $1}' | xargs kubectl describe pod -n "$namespace"
echo "$msg Checking again in ${sleep_time}s."
Expand Down

0 comments on commit d2a30f3

Please sign in to comment.