Merge pull request #26917 from fabioy/fix_multi_migs

Automatic merge from submit-queue

Handle multiple MIGs (single-zone) properly in GKE scripts.

Change the scripts for GKE to handle multiple node pools (MIGs) in the same zone. 

Fixes https://github.com/kubernetes/test-infra/issues/100.

[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/.github/PULL_REQUEST_TEMPLATE.md?pixel)]()
This commit is contained in:
k8s-merge-robot 2016-06-18 11:36:08 -07:00 committed by GitHub
commit 13cd6475c9
3 changed files with 31 additions and 12 deletions

View File

@ -270,8 +270,8 @@ function detect-nodes() {
# Detect minions created in the minion group # Detect minions created in the minion group
# #
# Note that this will only return the nodes from one of the cluster's instance # Note that this will only select nodes in the same zone as the
# groups, regardless of how many the cluster has. # cluster, meaning that it won't include all nodes in a multi-zone cluster.
# #
# Assumed vars: # Assumed vars:
# none # none
@ -280,11 +280,14 @@ function detect-nodes() {
function detect-node-names { function detect-node-names {
echo "... in gke:detect-node-names()" >&2 echo "... in gke:detect-node-names()" >&2
detect-project detect-project
detect-node-instance-group detect-node-instance-groups
NODE_NAMES=($(gcloud compute instance-groups managed list-instances \
"${NODE_INSTANCE_GROUP}" --zone "${ZONE}" --project "${PROJECT}" \
--format='value(instance)'))
NODE_NAMES=()
for group in "${NODE_INSTANCE_GROUPS[@]:-}"; do
NODE_NAMES+=($(gcloud compute instance-groups managed list-instances \
"${group}" --zone "${ZONE}" \
--project "${PROJECT}" --format='value(instance)'))
done
echo "NODE_NAMES=${NODE_NAMES[*]:-}" echo "NODE_NAMES=${NODE_NAMES[*]:-}"
} }
@ -299,13 +302,17 @@ function detect-node-names {
# ZONE # ZONE
# CLUSTER_NAME # CLUSTER_NAME
# Vars set: # Vars set:
# NODE_INSTANCE_GROUP # NODE_INSTANCE_GROUPS
function detect-node-instance-group { function detect-node-instance-groups {
echo "... in gke:detect-node-instance-group()" >&2 echo "... in gke:detect-node-instance-groups()" >&2
local url=$("${GCLOUD}" ${CMD_GROUP:-} container clusters describe \ local urls=$("${GCLOUD}" ${CMD_GROUP:-} container clusters describe \
--project="${PROJECT}" --zone="${ZONE}" \ --project="${PROJECT}" --zone="${ZONE}" \
--format='value(instanceGroupUrls)' "${CLUSTER_NAME}") --format='value(instanceGroupUrls)' "${CLUSTER_NAME}")
NODE_INSTANCE_GROUP="${url##*/}" urls=(${urls//;/ })
NODE_INSTANCE_GROUPS=()
for url in "${urls[@]:-}"; do
NODE_INSTANCE_GROUPS+=("${url##*/}")
done
} }
# SSH to a node by name ($1) and run a command ($2). # SSH to a node by name ($1) and run a command ($2).

View File

@ -25,6 +25,17 @@ kube::util::wait-for-jobs() {
return ${fail} return ${fail}
} }
# kube::util::join <delim> <list...>
# Concatenates the list elements with the delimiter passed as first parameter
#
# Ex: kube::util::join , a b c
# -> a,b,c
function kube::util::join {
local IFS="$1"
shift
echo "$*"
}
# Some useful colors. # Some useful colors.
if [[ -z "${color_start-}" ]]; then if [[ -z "${color_start-}" ]]; then
declare -r color_start="\033[" declare -r color_start="\033["

View File

@ -86,7 +86,8 @@ if [[ "${KUBERNETES_PROVIDER}" == "gce" ]]; then
fi fi
if [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then if [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
detect-node-instance-group detect-node-instance-groups
NODE_INSTANCE_GROUP=$(kube::util::join , NODE_INSTANCE_GROUPS)
fi fi
ginkgo_args=() ginkgo_args=()