From 15a44e4243737e361f2b99d4ddbfffbe23e18465 Mon Sep 17 00:00:00 2001 From: Fabio Yeon Date: Tue, 21 Jun 2016 14:10:09 -0700 Subject: [PATCH] Fix NODE_INSTANCE_GROUPS resolution in GKE to only include single cluster groups. Add NODE_INSTANCE_GROUPS_URLS for multi-zone groups. --- cluster/gke/util.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cluster/gke/util.sh b/cluster/gke/util.sh index ae7064d1c15..cf3bad41f5b 100755 --- a/cluster/gke/util.sh +++ b/cluster/gke/util.sh @@ -293,8 +293,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 @@ -303,15 +305,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 }