mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	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. []()
This commit is contained in:
		@@ -270,8 +270,8 @@ function detect-nodes() {
 | 
			
		||||
 | 
			
		||||
# Detect minions created in the minion group
 | 
			
		||||
#
 | 
			
		||||
# Note that this will only return the nodes from one of the cluster's instance
 | 
			
		||||
# groups, regardless of how many the cluster has.
 | 
			
		||||
# Note that this will only select nodes in the same zone as the
 | 
			
		||||
# cluster, meaning that it won't include all nodes in a multi-zone cluster.
 | 
			
		||||
#
 | 
			
		||||
# Assumed vars:
 | 
			
		||||
#   none
 | 
			
		||||
@@ -280,11 +280,14 @@ function detect-nodes() {
 | 
			
		||||
function detect-node-names {
 | 
			
		||||
  echo "... in gke:detect-node-names()" >&2
 | 
			
		||||
  detect-project
 | 
			
		||||
  detect-node-instance-group
 | 
			
		||||
  NODE_NAMES=($(gcloud compute instance-groups managed list-instances \
 | 
			
		||||
    "${NODE_INSTANCE_GROUP}" --zone "${ZONE}" --project "${PROJECT}" \
 | 
			
		||||
    --format='value(instance)'))
 | 
			
		||||
  detect-node-instance-groups
 | 
			
		||||
 | 
			
		||||
  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[*]:-}"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -299,13 +302,17 @@ function detect-node-names {
 | 
			
		||||
#   ZONE
 | 
			
		||||
#   CLUSTER_NAME
 | 
			
		||||
# Vars set:
 | 
			
		||||
#   NODE_INSTANCE_GROUP
 | 
			
		||||
function detect-node-instance-group {
 | 
			
		||||
  echo "... in gke:detect-node-instance-group()" >&2
 | 
			
		||||
  local url=$("${GCLOUD}" ${CMD_GROUP:-} container clusters describe \
 | 
			
		||||
#   NODE_INSTANCE_GROUPS
 | 
			
		||||
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}")
 | 
			
		||||
  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).
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,17 @@ kube::util::wait-for-jobs() {
 | 
			
		||||
  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.
 | 
			
		||||
if [[ -z "${color_start-}" ]]; then
 | 
			
		||||
  declare -r color_start="\033["
 | 
			
		||||
 
 | 
			
		||||
@@ -86,7 +86,8 @@ if [[ "${KUBERNETES_PROVIDER}" == "gce" ]]; then
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
 | 
			
		||||
  detect-node-instance-group
 | 
			
		||||
  detect-node-instance-groups
 | 
			
		||||
  NODE_INSTANCE_GROUP=$(kube::util::join , NODE_INSTANCE_GROUPS)
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
ginkgo_args=()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user