Skip to content
This repository was archived by the owner on Apr 27, 2020. It is now read-only.

Commit ec66c94

Browse files
Fix wait_until_pods_ready to exclude failed/succeeded pods (#24)
1 parent 4facaf0 commit ec66c94

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

assets/common.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ current_cluster() {
105105
kubectl config view -o "jsonpath={.clusters[?(@.name==\"${cluster}\")].cluster.server}"
106106
}
107107

108-
# wait_until_pods_ready waits for all pods to be ready in the current namespace.
108+
# wait_until_pods_ready waits for all pods to be ready in the current
109+
# namespace, which are excluded terminating and failed/succeeded pods.
109110
# $1: The number of seconds that waits until all pods are ready.
110111
# $2: The interval (sec) on which to check whether all pods are ready.
111112
# $3: A label selector to identify a set of pods which to check whether those are ready. Defaults to every pods in the namespace.
@@ -116,8 +117,15 @@ wait_until_pods_ready() {
116117

117118
echo "Waiting for pods to be ready for ${period}s (interval: ${interval}s, selector: ${selector:-''})"
118119

119-
# The list of "<pod-name> <ready(True|False)>" which is excluded terminating pods
120-
local template='{{range .items}}{{if not .metadata.deletionTimestamp}}{{.metadata.name}}{{range .status.conditions}}{{if eq .type "Ready"}} {{.status}}{{end}}{{end}}{{"\n"}}{{end}}{{end}}'
120+
# The list of "<pod-name> <ready(True|False)>" which is excluded terminating and failed/succeeded pods.
121+
local template="$(cat <<EOL
122+
{{- range .items -}}
123+
{{- if and (not .metadata.deletionTimestamp) (ne .status.phase "Failed") (ne .status.phase "Succeeded") -}}
124+
{{.metadata.name}}{{range .status.conditions}}{{if eq .type "Ready"}} {{.status}}{{end}}{{end}}{{"\n"}}
125+
{{- end -}}
126+
{{- end -}}
127+
EOL
128+
)"
121129

122130
local statuses not_ready ready
123131
for ((i=0; i<$period; i+=$interval)); do

0 commit comments

Comments
 (0)