playground: Deploy script update.
Update scripts moved to infrastructure repo.
MultiPart: 1/2
Change-Id: I5a6bd3aee1ae75b7bb474c3892071b0e4eed4dbb
diff --git a/go/src/playground/.gitignore b/go/src/playground/.gitignore
index 2e1a024..17618d0 100644
--- a/go/src/playground/.gitignore
+++ b/go/src/playground/.gitignore
@@ -1,3 +1,3 @@
-deploy/netrc
+netrc
config/*.json
!config/db-*-example.json
diff --git a/go/src/playground/Dockerfile b/go/src/playground/Dockerfile
index cc7b6db..765c3f2 100644
--- a/go/src/playground/Dockerfile
+++ b/go/src/playground/Dockerfile
@@ -8,8 +8,8 @@
RUN ln -s "$(which nodejs)" "$(dirname $(which nodejs))/node"
# Install Go. Note, the apt-get "golang" target is too old.
-RUN (cd /tmp; curl -O https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz)
-RUN tar -C /usr/local -xzf /tmp/go1.4.linux-amd64.tar.gz
+RUN (cd /tmp; curl -O https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz)
+RUN tar -C /usr/local -xzf /tmp/go1.4.2.linux-amd64.tar.gz
ENV PATH /usr/local/go/bin:$PATH
ENV HOME /root
@@ -22,7 +22,7 @@
# Note: This will be cached! If you want to re-build the docker image using
# fresh Vanadium code, you must pass "--no-cache" to the docker build command.
# See README.md.
-ADD deploy/netrc /root/.netrc
+ADD netrc /root/.netrc
RUN curl -u vanadium:D6HT]P,LrJ7e https://v.io/bootstrap | bash
RUN rm /root/.netrc
diff --git a/go/src/playground/README.md b/go/src/playground/README.md
index a9934ac..2f21342 100644
--- a/go/src/playground/README.md
+++ b/go/src/playground/README.md
@@ -23,7 +23,7 @@
Build the playground Docker image (this will take a while...):
- $ cp ~/.netrc $VANADIUM_ROOT/release/projects/playground/go/src/playground/deploy/netrc
+ $ cp ~/.netrc $VANADIUM_ROOT/release/projects/playground/go/src/playground/netrc
$ docker build -t playground $VANADIUM_ROOT/release/projects/playground/go/src/playground/.
Note: If you want to ensure an up-to-date version of Vanadium is installed in
@@ -66,4 +66,4 @@
make the client talk to your server. Add `?debug=1` to see debug info from
the builder.
-TODO: storage
+TODO(ivanpi): Describe storage.
diff --git a/go/src/playground/deploy/pool_template.json b/go/src/playground/deploy/pool_template.json
deleted file mode 100644
index a8d077a..0000000
--- a/go/src/playground/deploy/pool_template.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
- "template": {
- "action": {
- "commands": [
- "sudo mount /dev/sdb1 /mnt",
- "sudo docker load < /mnt/playground.tar.gz",
- "sudo docker run playground &> /dev/null || true",
- "start-stop-daemon --start -c ribrdb --exec /mnt/compilerd &> /tmp/compilerd.out &"
- ]
- },
- "healthChecks": [{
- "name": "healthz",
- "path": "/healthz",
- "port": "8181",
- }],
- "vmParams": {
- "machineType": "n1-standard-1",
- "baseInstanceName": "pg-replica",
- "disksToCreate": [{
- "boot": "true",
- "initializeParams": {
- "sourceImage": "https://www.googleapis.com/compute/v1/projects/google-containers/global/images/container-vm-v20140522",
- "diskSizeGb": "200"
- }
- }],
- "disksToAttach": [{
- "source": "pg-data-20140820"
- }],
- "networkInterfaces": [{
- "network": "playground",
- "accessConfigs": [{
- "type": "ONE_TO_ONE_NAT",
- "name": "External NAT"
- }]
- }]
- }
- }
-}
diff --git a/go/src/playground/deploy/update.sh b/go/src/playground/deploy/update.sh
deleted file mode 100755
index c39a8f2..0000000
--- a/go/src/playground/deploy/update.sh
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/bash
-# Copyright 2015 The Vanadium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-# Script to rebuild and deploy compilerd and the Docker image (builder) to the
-# playground backends.
-#
-# Usage:
-# gcutil ssh --project google.com:veyron playground-master
-# sudo su - veyron
-# v23 update
-# bash $VANADIUM_ROOT/release/projects/playground/go/src/playground/compilerd/update.sh
-
-set -e
-set -u
-
-readonly DATE=$(date +"%Y%m%d-%H%M%S")
-readonly DISK="pg-data-${DATE}"
-
-function unmount() {
- sudo umount /mnt
- gcloud compute --project "google.com:veyron" instances detach-disk --disk=${DISK} $(hostname) --zone us-central1-a
-}
-
-trap cleanup INT TERM EXIT
-
-function cleanup() {
- # Unset the trap so that it doesn't run again on exit.
- trap - INT TERM EXIT
- if [[ -e /mnt/compilerd ]]; then
- # The disk is still mounted on the master, which means it's not yet mounted
- # on any backends. It's safe to unmount and delete it.
- unmount
- gcloud compute --project "google.com:veyron" disks delete ${DISK} --zone "us-central1-a"
- fi
- sudo docker rm ${DISK} &> /dev/null || true
-}
-
-function main() {
- if [[ ! -e ~/.gitcookies ]]; then
- echo "Unable to access git, missing ~/.gitcookies"
- exit 1
- fi
- if [[ ! -e ~/.hgrc ]]; then
- echo "Unable to access mercurial, missing ~/.hgrc"
- exit 1
- fi
-
- local ROLLING="1"
- if [[ $# -gt 0 && ("$1" == "--no-rolling") ]]; then
- local ROLLING="0"
- fi
-
- gcloud compute --project "google.com:veyron" disks create ${DISK} --size "200" --zone "us-central1-a" --source-snapshot "pg-data-20140702" --type "pd-standard"
- gcloud compute --project "google.com:veyron" instances attach-disk --disk=${DISK} $(hostname) --zone us-central1-a
- sudo mount /dev/sdb1 /mnt
-
- # Build the docker image.
- cd ${VANADIUM_ROOT}/release/projects/playground/go/src/playground
- cp ~/.gitcookies ./builder/gitcookies
- cp ~/.hgrc ./builder/hgrc
- sudo docker build --no-cache -t playground .
- rm -f ./builder/gitcookies
- rm -f ./builder/hgrc
-
- # Export the docker image to disk.
- sudo docker save -o /mnt/playground.tar.gz playground
-
- # TODO(sadovsky): Before deploying the new playground image, we should run it
- # with real input and make sure it works (produces the expected output).
-
- # Copy the compilerd binary from the docker image to the disk.
- # NOTE(sadovsky): The purpose of the following line is to create a container
- # out of the docker image, so that we can copy out the compilerd binary.
- # Annoyingly, the only way to create the container is to run the image.
- # TODO(sadovsky): Why don't we just build compilerd using "v23 go install"?
- sudo docker run --name=${DISK} playground &> /dev/null || true
- sudo docker cp ${DISK}:/usr/local/vanadium/release/projects/playground/go/bin/compilerd /tmp
- sudo mv /tmp/compilerd /mnt/compilerd
- sudo docker rm ${DISK}
-
- # Detach the disk so the backends can mount it.
- unmount
-
- # Update the template to use the new disk.
- cd compilerd
- sed -i -e s/pg-data-20140820/${DISK}/ pool_template.json
- gcloud preview replica-pools --zone=us-central1-a update-template --template=pool_template.json playground-pool
- git checkout -- pool_template.json
-
- # Perform a rolling restart of all the replicas.
- INSTANCES=$(gcloud preview replica-pools --zone=us-central1-a replicas --pool=playground-pool list|grep name:|cut -d: -f2)
- for i in ${INSTANCES}; do
- gcloud preview replica-pools --zone=us-central1-a replicas --pool=playground-pool restart ${i}
- if [[ "$ROLLING" == "1" ]]; then
- sleep 5m
- fi
- done
-}
-
-main "$@"