Skip to content

Commit

Permalink
script: Retry pods readiness
Browse files Browse the repository at this point in the history
If pod readiness is checked before any pod is deployed, the command will result in an
error. Therefore, retry a few times to avoid unnecessary test failures.

Signed-off-by: Din Music <din.music@din-cloud.com>
  • Loading branch information
MusicDin committed Apr 17, 2024
1 parent 9374c44 commit b720d93
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scripts/test-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@ startTime=$(date +%s)
nodes=$(kubectl get nodes | awk 'NR>1 {print $1}')

echo "==> TEST: All pods ready"
kubectl wait --for=condition=ready pods --all -A --timeout=120s
# Wait for all pods to be ready. Retry a few times, as it may happen that
# cluster has no pods when check is ran, which will result in an error.
for i in {1..5}; do
podsReadiness=$(kubectl wait --for=condition=ready pods --all -A --timeout=10s)
if [ "$?" -eq 0 ]; then
break
else
echo "(attempt $i/5) Pods are still not ready. Retrying in 10 seconds..."
sleep 10
fi
done

echo "${podsReadiness}"

echo "==> TEST: DNS"
kubectl apply -f https://k8s.io/examples/admin/dns/dnsutils.yaml
Expand Down

0 comments on commit b720d93

Please sign in to comment.