diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index a6bc487af07..a0044667174 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -253,24 +253,6 @@ function detect-minion-names { echo "MINION_NAMES=${MINION_NAMES[*]}" >&2 } -# Waits until the number of running nodes in the instance group is equal to NUM_NODES -# -# Assumed vars: -# NODE_INSTANCE_PREFIX -# NUM_MINIONS -function wait-for-minions-to-run { - detect-project - local running_minions=0 - while [[ "${NUM_MINIONS}" != "${running_minions}" ]]; do - echo -e -n "${color_yellow}Waiting for minions to run. " - echo -e "${running_minions} out of ${NUM_MINIONS} running. Retrying.${color_norm}" - sleep 5 - running_minions=$((gcloud preview --project "${PROJECT}" instance-groups \ - --zone "${ZONE}" instances --group "${NODE_INSTANCE_PREFIX}-group" list \ - --running || true) | wc -l | xargs) - done -} - # Detect the information about the minions # # Assumed vars: @@ -695,16 +677,17 @@ function kube-up { write-node-env create-node-instance-template - gcloud preview managed-instance-groups --zone "${ZONE}" \ + gcloud compute instance-groups managed \ create "${NODE_INSTANCE_PREFIX}-group" \ --project "${PROJECT}" \ + --zone "${ZONE}" \ --base-instance-name "${NODE_INSTANCE_PREFIX}" \ --size "${NUM_MINIONS}" \ --template "${NODE_INSTANCE_PREFIX}-template" || true; - # TODO: this should be true when the above create managed-instance-group - # command returns, but currently it returns before the instances come up due - # to gcloud's deficiency. - wait-for-minions-to-run + gcloud compute instance-groups managed wait-until-stable \ + "${NODE_INSTANCE_PREFIX}-group" \ + --zone "${ZONE}" \ + --project "${PROJECT}" || true; detect-minion-names detect-master @@ -797,8 +780,8 @@ function kube-down { # The gcloud APIs don't return machine parseable error codes/retry information. Therefore the best we can # do is parse the output and special case particular responses we are interested in. - if gcloud preview managed-instance-groups --project "${PROJECT}" --zone "${ZONE}" describe "${NODE_INSTANCE_PREFIX}-group" &>/dev/null; then - deleteCmdOutput=$(gcloud preview managed-instance-groups --zone "${ZONE}" delete \ + if gcloud compute instance-groups managed describe --project "${PROJECT}" --zone "${ZONE}" "${NODE_INSTANCE_PREFIX}-group" &>/dev/null; then + deleteCmdOutput=$(gcloud compute instance-groups managed delete --zone "${ZONE}" \ --project "${PROJECT}" \ --quiet \ "${NODE_INSTANCE_PREFIX}-group") @@ -810,7 +793,7 @@ function kube-down { while [[ "$deleteCmdStatus" != "DONE" ]] do sleep 5 - deleteCmdOperationOutput=$(gcloud preview managed-instance-groups --zone "${ZONE}" --project "${PROJECT}" get-operation $deleteCmdOperationId) + deleteCmdOperationOutput=$(gcloud compute instance-groups managed --zone "${ZONE}" --project "${PROJECT}" get-operation $deleteCmdOperationId) deleteCmdStatus=$(echo $deleteCmdOperationOutput | grep -i "status:" | sed "s/.*status:[[:space:]]*\([^[:space:]]*\).*/\1/g") echo "Waiting for MIG deletion to complete. Current status: " $deleteCmdStatus done @@ -921,7 +904,7 @@ function kube-down { # $3: managed instance group name function get-template { # url is set to https://www.googleapis.com/compute/v1/projects/$1/global/instanceTemplates/