Skip to content

Commit

Permalink
Merge pull request #2289 from AndrewSirenko/single-az-warn
Browse files Browse the repository at this point in the history
Fast-fail `make e2e/single-az` if cluster has nodes in multiple AZs
  • Loading branch information
k8s-ci-robot authored Jan 24, 2025
2 parents e8454dd + a784434 commit 640b891
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions hack/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ else
exit 1
fi

# Fail single-az tests early if we know cluster is multi-az.
IGNORE_SINGLE_AZ_ERR=${IGNORE_SINGLE_AZ_ERR:="false"}
if [[ $IGNORE_SINGLE_AZ_ERR != "true" && "$GINKGO_FOCUS" =~ "single-az" ]]; then
# Get unique AZs of non-control-plane nodes
azs=$(kubectl get nodes \
--kubeconfig "${KUBECONFIG}" \
--selector '!node-role.kubernetes.io/control-plane' \
-o jsonpath='{.items[*].metadata.labels.topology\.kubernetes\.io/zone}' | tr " " "\n" | sort -u)

# Check if there's exactly one AZ and it matches $AWS_AVAILABILITY_ZONES
if [[ $(echo "$azs" | wc -w) -gt 1 ]] || [[ "$azs" != "$AWS_AVAILABILITY_ZONES" ]]; then
loudecho "ERROR. single-az tests require all worker nodes to be in a single availability zone (AZ) that matches env var \$AWS_AVAILABILITY_ZONES (Currently set as \"$AWS_AVAILABILITY_ZONES\"). Please delete nodes in other AZs. If you want to bypass this error, set env var IGNORE_SINGLE_AZ_ERR='true'"
exit 1
fi
fi

if [[ "$WINDOWS" == true ]]; then
NODE_OS_DISTRO="windows"
else
Expand Down

0 comments on commit 640b891

Please sign in to comment.