Make detect-node-names less brittle for G{C,K}E
This commit is contained in:
		@@ -273,13 +273,16 @@ function upload-server-tars() {
 | 
				
			|||||||
function detect-node-names {
 | 
					function detect-node-names {
 | 
				
			||||||
  detect-project
 | 
					  detect-project
 | 
				
			||||||
  INSTANCE_GROUPS=()
 | 
					  INSTANCE_GROUPS=()
 | 
				
			||||||
  INSTANCE_GROUPS+=($(gcloud compute instance-groups managed list --zone "${ZONE}" --project "${PROJECT}" | grep ${NODE_INSTANCE_PREFIX} | cut -f1 -d" " || true))
 | 
					  INSTANCE_GROUPS+=($(gcloud compute instance-groups managed list \
 | 
				
			||||||
 | 
					    --zone "${ZONE}" --project "${PROJECT}" \
 | 
				
			||||||
 | 
					    --regexp "${NODE_INSTANCE_PREFIX}-.+" \
 | 
				
			||||||
 | 
					    --format='value(instanceGroup)' || true))
 | 
				
			||||||
  NODE_NAMES=()
 | 
					  NODE_NAMES=()
 | 
				
			||||||
  if [[ -n "${INSTANCE_GROUPS[@]:-}" ]]; then
 | 
					  if [[ -n "${INSTANCE_GROUPS[@]:-}" ]]; then
 | 
				
			||||||
    for group in "${INSTANCE_GROUPS[@]}"; do
 | 
					    for group in "${INSTANCE_GROUPS[@]}"; do
 | 
				
			||||||
      NODE_NAMES+=($(gcloud compute instance-groups managed list-instances \
 | 
					      NODE_NAMES+=($(gcloud compute instance-groups managed list-instances \
 | 
				
			||||||
        "${group}" --zone "${ZONE}" --project "${PROJECT}" \
 | 
					        "${group}" --zone "${ZONE}" --project "${PROJECT}" \
 | 
				
			||||||
        --format=yaml | grep instance: | cut -d ' ' -f 2))
 | 
					        --format='value(instance)'))
 | 
				
			||||||
    done
 | 
					    done
 | 
				
			||||||
    echo "INSTANCE_GROUPS=${INSTANCE_GROUPS[*]}" >&2
 | 
					    echo "INSTANCE_GROUPS=${INSTANCE_GROUPS[*]}" >&2
 | 
				
			||||||
    echo "NODE_NAMES=${NODE_NAMES[*]}" >&2
 | 
					    echo "NODE_NAMES=${NODE_NAMES[*]}" >&2
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -249,10 +249,7 @@ function detect-node-names {
 | 
				
			|||||||
  detect-node-instance-group
 | 
					  detect-node-instance-group
 | 
				
			||||||
  NODE_NAMES=($(gcloud compute instance-groups managed list-instances \
 | 
					  NODE_NAMES=($(gcloud compute instance-groups managed list-instances \
 | 
				
			||||||
    "${NODE_INSTANCE_GROUP}" --zone "${ZONE}" --project "${PROJECT}" \
 | 
					    "${NODE_INSTANCE_GROUP}" --zone "${ZONE}" --project "${PROJECT}" \
 | 
				
			||||||
    --format=yaml | grep instance: | cut -d ' ' -f 2))
 | 
					    --format='value(instance)'))
 | 
				
			||||||
 | 
					 | 
				
			||||||
  # Strip path if return value is selflink
 | 
					 | 
				
			||||||
  NODE_NAMES=($(for i in ${NODE_NAMES[@]}; do basename "$i"; done))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  echo "NODE_NAMES=${NODE_NAMES[*]}"
 | 
					  echo "NODE_NAMES=${NODE_NAMES[*]}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user