Commit d2ff21d3 authored by Brendan Burns's avatar Brendan Burns

Wait for not pending, not for running.

When failures occur, we go to 'Terminated' which can cause indefinite blocking.
parent 58ba3c7f
...@@ -30,7 +30,7 @@ function teardown() { ...@@ -30,7 +30,7 @@ function teardown() {
${KUBECFG} delete pods/liveness-http ${KUBECFG} delete pods/liveness-http
} }
function waitForRunning() { function waitForNotPending() {
pod_id_list=$($KUBECFG '-template={{range.items}}{{.id}} {{end}}' -l test=liveness list pods) pod_id_list=$($KUBECFG '-template={{range.items}}{{.id}} {{end}}' -l test=liveness list pods)
# Pod turn up on a clean cluster can take a while for the docker image pull. # Pod turn up on a clean cluster can take a while for the docker image pull.
all_running=0 all_running=0
...@@ -40,7 +40,7 @@ function waitForRunning() { ...@@ -40,7 +40,7 @@ function waitForRunning() {
all_running=1 all_running=1
for id in $pod_id_list; do for id in $pod_id_list; do
current_status=$($KUBECFG -template '{{.currentState.status}}' get pods/$id) || true current_status=$($KUBECFG -template '{{.currentState.status}}' get pods/$id) || true
if [[ "$current_status" != "Running" ]]; then if [[ "$current_status" == "Pending" ]]; then
all_running=0 all_running=0
break break
fi fi
...@@ -58,7 +58,7 @@ function waitForRunning() { ...@@ -58,7 +58,7 @@ function waitForRunning() {
trap "teardown" EXIT trap "teardown" EXIT
${KUBECFG} -c ${KUBE_ROOT}/examples/liveness/http-liveness.yaml create pods ${KUBECFG} -c ${KUBE_ROOT}/examples/liveness/http-liveness.yaml create pods
waitForRunning waitForNotPending
before=$(${KUBECFG} '-template={{.currentState.info.liveness.restartCount}}' get pods/liveness-http) before=$(${KUBECFG} '-template={{.currentState.info.liveness.restartCount}}' get pods/liveness-http)
...@@ -67,7 +67,7 @@ for i in $(seq 1 24); do ...@@ -67,7 +67,7 @@ for i in $(seq 1 24); do
sleep 10 sleep 10
after=$(${KUBECFG} '-template={{.currentState.info.liveness.restartCount}}' get pods/liveness-http) after=$(${KUBECFG} '-template={{.currentState.info.liveness.restartCount}}' get pods/liveness-http)
echo "Restarts: ${after} > ${before}" echo "Restarts: ${after} > ${before}"
if [[ "${after}" > "${before} ]]; then if [[ "${after}" > "${before}" ]]; then
break break
fi fi
done done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment