Skip to content

Commit

Permalink
Merge pull request kubernetes#28354 from gmarek/automated-cherry-pick…
Browse files Browse the repository at this point in the history
…-of-#27877-upstream-release-1.2

Automated cherry pick of kubernetes#27877
  • Loading branch information
roberthbailey committed Jul 1, 2016
2 parents 873296f + 8afcd4d commit b9d78f4
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions cluster/gce/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ function prepare-node-upgrade() {
# through all create-node-instance-template implementations).
local template_name=$(get-template-name-from-version ${SANITIZED_VERSION})
create-node-instance-template "${template_name}"
# The following is echo'd so that callers can get the template name.
echo $template_name
echo "== Finished preparing node upgrade (to ${KUBE_VERSION}). ==" >&2
}

Expand All @@ -217,8 +215,15 @@ function do-node-upgrade() {
# NOTE(zmerlynn): If you are changing this gcloud command, update
# test/e2e/cluster_upgrade.go to match this EXACTLY.
local template_name=$(get-template-name-from-version ${SANITIZED_VERSION})
local old_templates=()
local updates=()
for group in ${INSTANCE_GROUPS[@]}; do
gcloud alpha compute rolling-updates \
old_templates+=($(gcloud compute instance-groups managed list \
--project="${PROJECT}" \
--zone="${ZONE}" \
--regexp="${group}" \
--format='value(instanceTemplate)' || true))
update=$(gcloud alpha compute rolling-updates \
--project="${PROJECT}" \
--zone="${ZONE}" \
start \
Expand All @@ -227,10 +232,36 @@ function do-node-upgrade() {
--instance-startup-timeout=300s \
--max-num-concurrent-instances=1 \
--max-num-failed-instances=0 \
--min-instance-update-time=0s
--min-instance-update-time=0s 2>&1)
id=$(echo "${update}" | grep "Started" | cut -d '/' -f 11 | cut -d ']' -f 1)
updates+=("${id}")
done

# Wait until rolling updates are finished.
for update in ${updates[@]}; do
while true; do
result=$(gcloud alpha compute rolling-updates \
--project="${PROJECT}" \
--zone="${ZONE}" \
describe \
${update} \
--format='value(status)' || true)
if [ $result = "ROLLED_OUT" ]; then
echo "Rolling update ${update} is ${result} state and finished."
break
fi
echo "Rolling update ${update} is stil in ${result} state."
sleep 10
done
done

# TODO(zmerlynn): Wait for the rolling-update to finish.
# Remove the old templates.
for tmpl in ${old_templates[@]}; do
gcloud compute instance-templates delete \
--quiet \
--project="${PROJECT}" \
"${tmpl}" || true
done

echo "== Finished upgrading nodes to ${KUBE_VERSION}. ==" >&2
}
Expand Down

0 comments on commit b9d78f4

Please sign in to comment.