mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #67639 from mborsz/validate-cluster
Automatic merge from submit-queue (batch tested with PRs 67655, 67639). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix validate-cluster.sh for clusters with more than 500 nodes. **What this PR does / why we need it**: Without the change, validate-cluster.sh counts nodes using 'wc -l' minus one (header). kubectl repeats header every 500 rows, so for bigger clusters this doesn't work. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #67597 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
commit
0e31372b2f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user