Skip to content

Commit a3d532c

Browse files
committed
cmd/godoc: add make publish to migrate traffic
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#27205. Change-Id: Iae19b9a6f77d09246a1332c7ec9eceec449cdba8 Reviewed-on: https://go-review.googlesource.com/c/139239 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
1 parent 140737f commit a3d532c

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

cmd/godoc/Makefile

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ usage:
1919
@echo "See Makefile and README.godoc-app"
2020
@exit 1
2121

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

33-
push: docker
33+
docker-push: docker-build
3434
docker push $(DOCKER_TAG)
3535

36-
deploy: push
36+
deploy:
3737
gcloud -q app deploy app.prod.yaml \
38-
--project $(GCP_PROJECT) \
38+
--project=$(GCP_PROJECT) \
3939
--no-promote \
40-
--image-url $(DOCKER_TAG)
40+
--image-url=$(DOCKER_TAG)
4141

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

50+
get-latest-id:
51+
@gcloud app versions list \
52+
--service=default \
53+
--project=$(GCP_PROJECT) \
54+
--sort-by=~version.createTime \
55+
--format='value(version.id)' \
56+
--limit 1 | cut -f1 # NOTE(cbro): gcloud prints out createTime as the second field.
57+
5058
regtest:
5159
go test -v \
5260
-regtest.host=$(shell make get-latest-url) \
5361
-run=Live
62+
63+
publish: regtest
64+
gcloud -q app services set-traffic default \
65+
--splits=$(shell make get-latest-id)=1 \
66+
--project=$(GCP_PROJECT)
67+
68+
@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
69+
@echo Stop and/or delete old versions:
70+
@echo "https://console.cloud.google.com/appengine/versions?project=$(GCP_PROJECT)&serviceId=default&versionssize=50"
71+
@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

cmd/godoc/README.godoc-app

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Running locally, in production mode, using Docker
3737

3838
Build the app's Docker container:
3939

40-
make docker
40+
make docker-build
4141

4242
Make sure redis is running on port 6379:
4343

@@ -68,17 +68,19 @@ Deploying to golang.org
6868

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

71-
make deploy
71+
make docker-push deploy
7272

73-
Run regression tests:
73+
Point the load balancer to the newly deployed version:
74+
(This also runs regression tests)
7475

75-
make regtest
76+
make publish
7677

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

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

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

8385
Troubleshooting
8486
---------------

0 commit comments

Comments
 (0)