diff --git a/cluster/gke/util.sh b/cluster/gke/util.sh index 0fb3cef8cd9..e0f57f49c25 100755 --- a/cluster/gke/util.sh +++ b/cluster/gke/util.sh @@ -296,8 +296,10 @@ function detect-node-names { # Detect instance group name generated by gke. # -# Note that this will only select instance groups in the same zone as the -# cluster, meaning that it won't include all groups in a multi-zone cluster. +# Note that the NODE_INSTANCE_GROUPS var will only have instance groups in the +# same zone as the cluster, meaning that it won't include all groups in a +# multi-zone cluster. The ALL_INSTANCE_GROUP_URLS will contain all the +# instance group URLs, which include multi-zone groups. # # Assumed vars: # GCLOUD @@ -306,15 +308,20 @@ function detect-node-names { # CLUSTER_NAME # Vars set: # NODE_INSTANCE_GROUPS +# ALL_INSTANCE_GROUP_URLS function detect-node-instance-groups { echo "... in gke:detect-node-instance-groups()" >&2 local urls=$("${GCLOUD}" ${CMD_GROUP:-} container clusters describe \ --project="${PROJECT}" --zone="${ZONE}" \ --format='value(instanceGroupUrls)' "${CLUSTER_NAME}") urls=(${urls//;/ }) + ALL_INSTANCE_GROUP_URLS=${urls[*]} NODE_INSTANCE_GROUPS=() for url in "${urls[@]:-}"; do - NODE_INSTANCE_GROUPS+=("${url##*/}") + local igm_zone=$(expr match ${url} '.*/zones/\([a-z0-9-]*\)/') + if [[ "${igm_zone}" == "${ZONE}" ]]; then + NODE_INSTANCE_GROUPS+=("${url##*/}") + fi done }