mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-31 05:40:42 +00:00 
			
		
		
		
	Merge pull request #81345 from k-toyoda-pi/fix_shellcheck_validate-cluster
Fix shellcheck failures in cluster/validate-cluster.sh
This commit is contained in:
		| @@ -39,7 +39,7 @@ function kubectl_retry() { | |||||||
|   while ! "${KUBE_ROOT}/cluster/kubectl.sh" "$@"; do |   while ! "${KUBE_ROOT}/cluster/kubectl.sh" "$@"; do | ||||||
|     tries=$((tries-1)) |     tries=$((tries-1)) | ||||||
|     if [[ ${tries} -le 0 ]]; then |     if [[ ${tries} -le 0 ]]; then | ||||||
|       echo "('kubectl $@' failed, giving up)" >&2 |       echo "('kubectl $*' failed, giving up)" >&2 | ||||||
|       return 1 |       return 1 | ||||||
|     fi |     fi | ||||||
|     echo "(kubectl failed, will retry ${tries} times)" >&2 |     echo "(kubectl failed, will retry ${tries} times)" >&2 | ||||||
| @@ -59,8 +59,8 @@ if [[ "${KUBERNETES_PROVIDER:-}" == "gce" ]]; then | |||||||
|   echo "Validating gce cluster, MULTIZONE=${MULTIZONE:-}" |   echo "Validating gce cluster, MULTIZONE=${MULTIZONE:-}" | ||||||
|   # In multizone mode we need to add instances for all nodes in the region. |   # In multizone mode we need to add instances for all nodes in the region. | ||||||
|   if [[ "${MULTIZONE:-}" == "true" ]]; then |   if [[ "${MULTIZONE:-}" == "true" ]]; then | ||||||
|     EXPECTED_NUM_NODES=$(gcloud -q compute instances list --project="${PROJECT}" --format=[no-heading] \ |     EXPECTED_NUM_NODES=$(gcloud -q compute instances list --project="${PROJECT}" --format="[no-heading]" \ | ||||||
|       --filter="(name ~ '${NODE_INSTANCE_PREFIX}.*' OR name ~ '${WINDOWS_NODE_INSTANCE_PREFIX}.*') AND zone:($(gcloud -q compute zones list --project="${PROJECT}" --filter=region=${REGION} --format=csv[no-heading]\(name\) | tr "\n" "," | sed  "s/,$//"))" | wc -l) |       --filter="(name ~ '${NODE_INSTANCE_PREFIX}.*' OR name ~ '${WINDOWS_NODE_INSTANCE_PREFIX}.*') AND zone:($(gcloud -q compute zones list --project="${PROJECT}" --filter=region="${REGION}" --format="csv[no-heading](name)" | tr "\n" "," | sed  "s/,$//"))" | wc -l) | ||||||
|     echo "Computing number of nodes, NODE_INSTANCE_PREFIX=${NODE_INSTANCE_PREFIX}, REGION=${REGION}, EXPECTED_NUM_NODES=${EXPECTED_NUM_NODES}" |     echo "Computing number of nodes, NODE_INSTANCE_PREFIX=${NODE_INSTANCE_PREFIX}, REGION=${REGION}, EXPECTED_NUM_NODES=${EXPECTED_NUM_NODES}" | ||||||
|   fi |   fi | ||||||
| else | else | ||||||
| @@ -112,7 +112,7 @@ while true; do | |||||||
|   node="${node%.}" |   node="${node%.}" | ||||||
|   if [ "${res}" -ne "0" ]; then |   if [ "${res}" -ne "0" ]; then | ||||||
|     if [[ "${attempt}" -gt "${last_run:-$MAX_ATTEMPTS}" ]]; then |     if [[ "${attempt}" -gt "${last_run:-$MAX_ATTEMPTS}" ]]; then | ||||||
|       echo -e "${color_red} Failed to get nodes.${color_norm}" |       echo -e "${color_red:-} Failed to get nodes.${color_norm:-}" | ||||||
|       exit 1 |       exit 1 | ||||||
|     else |     else | ||||||
|       continue |       continue | ||||||
| @@ -134,11 +134,11 @@ while true; do | |||||||
|     break |     break | ||||||
|   else |   else | ||||||
|     if [[ "${REQUIRED_NUM_NODES}" -le "${ready}" ]]; then |     if [[ "${REQUIRED_NUM_NODES}" -le "${ready}" ]]; then | ||||||
|       echo -e "${color_green}Found ${REQUIRED_NUM_NODES} Nodes, allowing additional ${ADDITIONAL_ITERATIONS} iterations for other Nodes to join.${color_norm}" |       echo -e "${color_green:-}Found ${REQUIRED_NUM_NODES} Nodes, allowing additional ${ADDITIONAL_ITERATIONS} iterations for other Nodes to join.${color_norm}" | ||||||
|       last_run="${last_run:-$((attempt + ADDITIONAL_ITERATIONS - 1))}" |       last_run="${last_run:-$((attempt + ADDITIONAL_ITERATIONS - 1))}" | ||||||
|     fi |     fi | ||||||
|     if [[ "${attempt}" -gt "${last_run:-$MAX_ATTEMPTS}" ]]; then |     if [[ "${attempt}" -gt "${last_run:-$MAX_ATTEMPTS}" ]]; then | ||||||
|       echo -e "${color_yellow}Detected ${ready} ready nodes, found ${found} nodes out of expected ${EXPECTED_NUM_NODES}. Your cluster may not be fully functional.${color_norm}" |       echo -e "${color_yellow:-}Detected ${ready} ready nodes, found ${found} nodes out of expected ${EXPECTED_NUM_NODES}. Your cluster may not be fully functional.${color_norm}" | ||||||
|       kubectl_retry get nodes |       kubectl_retry get nodes | ||||||
|       if [[ "${REQUIRED_NUM_NODES}" -gt "${ready}" ]]; then |       if [[ "${REQUIRED_NUM_NODES}" -gt "${ready}" ]]; then | ||||||
|         exit 1 |         exit 1 | ||||||
|   | |||||||
| @@ -10,4 +10,3 @@ | |||||||
| ./cluster/gce/util.sh | ./cluster/gce/util.sh | ||||||
| ./cluster/log-dump/log-dump.sh | ./cluster/log-dump/log-dump.sh | ||||||
| ./cluster/pre-existing/util.sh | ./cluster/pre-existing/util.sh | ||||||
| ./cluster/validate-cluster.sh |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user