Fix NODE_INSTANCE_GROUPS resolution in GKE to only

include single cluster groups. Add NODE_INSTANCE_GROUPS_URLS for
multi-zone groups.
This commit is contained in:
Fabio Yeon 2016-06-21 14:10:09 -07:00
parent d82c3023a8
commit 15a44e4243

View File

@ -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
}