Fix validate-cluster.sh for clusters with more than 500 nodes.

pull/8/head
Maciej Borsz 2018-08-21 09:54:46 +02:00
parent 54dbbc41df
commit c6a852fe74
1 changed files with 10 additions and 3 deletions

View File

@ -98,7 +98,13 @@ while true; do
#
# We are assigning the result of kubectl_retry get nodes operation to the res
# variable in that way, to prevent stopping the whole script on an error.
node=$(kubectl_retry get nodes) && res="$?" || res="$?"
#
# Bash command substitution $(kubectl_...) removes all trailing whitespaces
# which are important for line counting.
# Use trick from https://unix.stackexchange.com/a/383411 to avoid
# newline truncation.
node=$(kubectl_retry get nodes --no-headers; ret=$?; echo .; exit "$ret") && res="$?" || res="$?"
node="${node%.}"
if [ "${res}" -ne "0" ]; then
if [[ "${attempt}" -gt "${last_run:-$MAX_ATTEMPTS}" ]]; then
echo -e "${color_red} Failed to get nodes.${color_norm}"
@ -107,8 +113,9 @@ while true; do
continue
fi
fi
found=$(($(echo "${node}" | wc -l) - 1))
ready=$(($(echo "${node}" | grep -v "NotReady" | wc -l ) - 1))
found=$(echo -n "${node}" | wc -l)
# Use grep || true so that empty result doesn't return nonzero exit code.
ready=$(echo -n "${node}" | grep -c -v "NotReady" || true)
if (( "${found}" == "${EXPECTED_NUM_NODES}" )) && (( "${ready}" == "${EXPECTED_NUM_NODES}")); then
break