Skip to content

Commit

Permalink
[release-branch.go1.11] cmd/godoc: add make publish to migrate traffic
Browse files Browse the repository at this point in the history
Also rename `make build` and `make push` to `make docker-build` and
`make docker-push` in preparation to introduce Cloud Build (removing
the dependency on Docker).

Updates golang/go#28893
Updates golang/go#27205

Change-Id: Iae19b9a6f77d09246a1332c7ec9eceec449cdba8
Reviewed-on: https://go-review.googlesource.com/c/139239
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/150681
  • Loading branch information
broady authored and dmitshur committed Nov 21, 2018
1 parent f160a88 commit 6f8a893
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 13 deletions.
32 changes: 25 additions & 7 deletions cmd/godoc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ usage:
@echo "See Makefile and README.godoc-app"
@exit 1

docker: Dockerfile.prod
docker-build: Dockerfile.prod
# NOTE(cbro): move up in directory to include entire tools repo.
cd ../..; docker build \
-f cmd/godoc/Dockerfile.prod \
Expand All @@ -30,24 +30,42 @@ docker: Dockerfile.prod
--tag=$(DOCKER_TAG) \
.

push: docker
docker-push: docker-build
docker push $(DOCKER_TAG)

deploy: push
deploy:
gcloud -q app deploy app.prod.yaml \
--project $(GCP_PROJECT) \
--project=$(GCP_PROJECT) \
--no-promote \
--image-url $(DOCKER_TAG)
--image-url=$(DOCKER_TAG)

get-latest-url:
@gcloud app versions list \
-s default \
--project $(GCP_PROJECT) \
--service=default \
--project=$(GCP_PROJECT) \
--sort-by=~version.createTime \
--format='value(version.versionUrl)' \
--limit 1 | cut -f1 # NOTE(cbro): gcloud prints out createTime as the second field.

get-latest-id:
@gcloud app versions list \
--service=default \
--project=$(GCP_PROJECT) \
--sort-by=~version.createTime \
--format='value(version.id)' \
--limit 1 | cut -f1 # NOTE(cbro): gcloud prints out createTime as the second field.

regtest:
go test -v \
-regtest.host=$(shell make get-latest-url) \
-run=Live

publish: regtest
gcloud -q app services set-traffic default \
--splits=$(shell make get-latest-id)=1 \
--project=$(GCP_PROJECT)

@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@echo Stop and/or delete old versions:
@echo "https://console.cloud.google.com/appengine/versions?project=$(GCP_PROJECT)&serviceId=default&versionssize=50"
@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14 changes: 8 additions & 6 deletions cmd/godoc/README.godoc-app
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Running locally, in production mode, using Docker

Build the app's Docker container:

make docker
make docker-build

Make sure redis is running on port 6379:

Expand Down Expand Up @@ -68,17 +68,19 @@ Deploying to golang.org

Build the image, push it to gcr.io, and deploy to Flex:

make deploy
make docker-push deploy

Run regression tests:
Point the load balancer to the newly deployed version:
(This also runs regression tests)

make regtest
make publish

Go to the console to migrate traffic to the newly deployed version:
Stop and/or delete down any very old versions. (Stopped versions can be re-started.)
Keep at least one older verson to roll back to, just in case.
You can also migrate traffic to the new version via this UI.

https://console.cloud.google.com/appengine/versions?project=golang-org&serviceId=default&versionssize=50

Shut down any very old versions (keep at least one to roll back to, just in case).

Troubleshooting
---------------
Expand Down

0 comments on commit 6f8a893

Please sign in to comment.