taler-deployment

Deployment scripts and configuration files
Log | Files | Refs | README

commit ca74777ce76302eb14780047446bec1c521e0e17
parent eefbfc83920e0075df18562223a7e967cb574b38
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Tue, 16 Apr 2019 21:38:39 +0200

BB.

Give each color a worker, and make 'test' manage the
color switch (by having itself a dedicate worker.)

Diffstat:
Mbin/taler-deployment-switch-demo-blue | 1+
Mbin/taler-deployment-switch-demo-green | 1+
Mbin/taler-deployment-switch-test-blue | 1+
Mbin/taler-deployment-switch-test-green | 1+
Mbuildbot/build.sh | 12++++++------
Mbuildbot/checks.sh | 45+++++++++++++++++----------------------------
Mbuildbot/config.sh | 18++++++------------
Mbuildbot/keys.sh | 18++++++------------
Mbuildbot/master.cfg | 43+++++++++++++++++++++++++------------------
Mbuildbot/restart.sh | 18++++++------------
Mbuildbot/sign.sh | 18++++++------------
Mbuildbot/switch.sh | 2+-
Mbuildbot/top_reserve.sh | 2+-
13 files changed, 78 insertions(+), 102 deletions(-)

diff --git a/bin/taler-deployment-switch-demo-blue b/bin/taler-deployment-switch-demo-blue @@ -12,3 +12,4 @@ ln -s /home/demo-blue/sockets /home/demo/sockets ln -s /home/demo-blue/landing /home/demo/landing ln -s /home/demo-blue/auditor /home/demo/auditor echo "demo-blue" > /home/demo/active +echo "demo-green" > /home/demo/nonactive diff --git a/bin/taler-deployment-switch-demo-green b/bin/taler-deployment-switch-demo-green @@ -12,3 +12,4 @@ ln -s /home/demo-green/sockets /home/demo/sockets ln -s /home/demo-green/landing /home/demo/landing ln -s /home/demo-green/auditor /home/demo/auditor echo "demo-green" > /home/demo/active +echo "demo-blue" > /home/demo/nonactive diff --git a/bin/taler-deployment-switch-test-blue b/bin/taler-deployment-switch-test-blue @@ -12,3 +12,4 @@ ln -s /home/test-blue/sockets /home/test/sockets ln -s /home/test-blue/landing /home/test/landing ln -s /home/test-blue/auditor /home/test/auditor echo "test-blue" > /home/test/active +echo "test-green" > /home/test/nonactive diff --git a/bin/taler-deployment-switch-test-green b/bin/taler-deployment-switch-test-green @@ -12,3 +12,4 @@ ln -s /home/test-green/sockets /home/test/sockets ln -s /home/test-green/landing /home/test/landing ln -s /home/test-green/auditor /home/test/auditor echo "test-green" > /home/test/active +echo "test-blue" > /home/test/nonactive diff --git a/buildbot/build.sh b/buildbot/build.sh @@ -1,11 +1,11 @@ #!/bin/bash -active=$(sudo -u test cat /home/test/active) -nonactive="test-blue" -echo "Active party: ${active}" +source "${HOME}/activate" +ACTIVE_COLOR="$(cat /home/test/active)" -if test $active = "test-blue"; then - nonactive="test-green" +if test "${TALER_ENV_COLOR}" = "${ACTIVE_COLOR}"; then + echo "I'm the active color, no need to compile and switch!" + exit 0 fi PAUSE_LOCKFILE=/tmp/buildbot_pause.lock @@ -17,4 +17,4 @@ echo "The Buildbot is paused, remove ${PAUSE_LOCKFILE} to resume." exit 2 fi -sudo -u $nonactive bash -c 'source $HOME/activate; taler-deployment-build' +taler-deployment-build' diff --git a/buildbot/checks.sh b/buildbot/checks.sh @@ -1,30 +1,19 @@ #!/bin/bash - -DEPLOYMENT="test" -DOMAIN="wild.gv.taler.net" - -if test "stable" = "${BRANCH}"; then - DEPLOYMENT="demo" +if test -z "${DEPLOYMENT}"; then + echo Please provide DEPLOYMENT env var: 'test' or 'demo' + exit 1 fi - ## -# If the value stays as 'dummy', then the color switch -# is ignored and the active one between blue/green will -# receive the connections. -nonactive="dummy" +# Will stay as 'dummy' for 'demo' DEPLOYMENTs since we do +# want to get this value ignored and the active deployment +# to be checked. +NONACTIVE_COLOR="notneeded" -if test "${DEPLOYMENT}" = "test"; then - active=$(sudo -u ${DEPLOYMENT} cat /home/${DEPLOYMENT}/active) - nonactive="blue" - - echo "Active party: ${active}" - - if test "$active" = "test-blue"; then - nonactive="green" - fi -fi +if test "test" = "${DEPLOYMENT}"; then + NONACTIVE_COLOR="$(cat /home/test/nonactive)" +fi error_stringify () { @@ -40,7 +29,7 @@ error_fmt="%s (http status code: %s)/(curl exit code: %s - %s)\n" URL="https://exchange.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ - -H "X-Taler-Deployment-Color: $nonactive" \ + -H "X-Taler-Deployment-Color: "${ACTIVE_COLOR}" \ -s "$URL" -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then @@ -53,7 +42,7 @@ fi URL="http://backend.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ - -H "X-Taler-Deployment-Color: $nonactive" \ + -H "X-Taler-Deployment-Color: "${ACTIVE_COLOR}" \ -s $URL \ --header "Authorization: ApiKey sandbox" \ -o /dev/null \ @@ -69,7 +58,7 @@ fi URL="https://shop.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ - -H "X-Taler-Deployment-Color: $nonactive" \ + -H "X-Taler-Deployment-Color: "${ACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then @@ -82,7 +71,7 @@ fi URL="https://survey.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ - -H "X-Taler-Deployment-Color: $nonactive" \ + -H "X-Taler-Deployment-Color: "${ACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then @@ -95,7 +84,7 @@ fi URL="https://donations.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ - -H "X-Taler-Deployment-Color: $nonactive" \ + -H "X-Taler-Deployment-Color: "${ACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then @@ -108,7 +97,7 @@ fi URL="https://bank.${DEPLOYMENT}.${DOMAIN}/" http_status_code=$(curl \ - -H "X-Taler-Deployment-Color: $nonactive" \ + -H "X-Taler-Deployment-Color: "${ACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 302 = $http_status_code; then @@ -121,7 +110,7 @@ fi URL="https://${DEPLOYMENT}.${DOMAIN}/en/index.html" http_status_code=$(curl \ - -H "X-Taler-Deployment-Color: $nonactive" \ + -H "X-Taler-Deployment-Color: "${ACTIVE_COLOR}" \ -s $URL -o /dev/null \ -w "%{http_code}") if ! test 200 = $http_status_code; then diff --git a/buildbot/config.sh b/buildbot/config.sh @@ -1,17 +1,11 @@ #!/bin/bash -DEPLOYMENT="test" +source "${HOME}/activate" +ACTIVE_COLOR="$(cat /home/test/active)" -if test "stable" = ${BRANCH}; then - DEPLOYMENT="demo" +if test "${TALER_ENV_COLOR}" = "${ACTIVE_COLOR}"; then + echo "I'm the active color, no need to compile and switch!" + exit 0 fi -active=$(sudo -u ${DEPLOYMENT} cat /home/${DEPLOYMENT}/active) -nonactive="${DEPLOYMENT}-blue" -echo "Active party: ${active}" - -if test "$active" = "${DEPLOYMENT}-blue"; then - nonactive="${DEPLOYMENT}-green" -fi - -sudo -u $nonactive bash -c 'source $HOME/activate; taler-deployment-config-generate' +taler-deployment-config-generate' diff --git a/buildbot/keys.sh b/buildbot/keys.sh @@ -1,17 +1,11 @@ #!/bin/bash -DEPLOYMENT="test" +source "${HOME}/activate" +ACTIVE_COLOR="$(cat /home/test/active)" -if test "stable" = ${BRANCH}; then - DEPLOYMENT="demo" +if test "${TALER_ENV_COLOR}" = "${ACTIVE_COLOR}"; then + echo "I'm the active color, no need to compile and switch!" + exit 0 fi -active=$(sudo -u ${DEPLOYMENT} cat /home/${DEPLOYMENT}/active) -nonactive="${DEPLOYMENT}-blue" -echo "Active party: ${active}" - -if test $active = "${DEPLOYMENT}-blue"; then - nonactive="${DEPLOYMENT}-green" -fi - -sudo -u $nonactive bash -c 'source $HOME/activate; taler-deployment-keyup' +taler-deployment-keyup' diff --git a/buildbot/master.cfg b/buildbot/master.cfg @@ -27,7 +27,9 @@ c["workers"] = [ worker.Worker("lcov-worker", "lcov-pass"), worker.Worker("selenium-worker", "selenium-pass"), worker.Worker("doc-worker", "doc-pass"), - worker.Worker("switcher-worker", "switcher-pass"), + worker.Worker("builder-worker-green", "green-pass"), + worker.Worker("builder-worker-blue", "blue-pass"), + worker.Worker("testswitcher-worker", "testswitcher-pass"), worker.Worker("debug-worker", "debug-pass"), worker.Worker("lint-worker", "lint-pass"), worker.Worker("demo-worker", "demo-pass"), @@ -115,7 +117,7 @@ ALL_SCHEDULER = schedulers.SingleBranchScheduler( "merchant|deployment|donations|twister|" "blog|help|survey|landing|playground"), treeStableTimer=None, - builderNames=["switcher-builder"]) + builderNames=["builder-builder"]) # Scheduler monitoring the help.git repo; a forgotten repo we # use to test BB. @@ -263,29 +265,27 @@ TIP_RESERVE_TOPPER_FACTORY.addStep(ShellCommand( command=["./top_reserve.sh"], workdir="build/buildbot")) -SWITCHER_FACTORY = util.BuildFactory() -SWITCHER_FACTORY.addStep(git_step( +BUILD_FACTORY = util.BuildFactory() +BUILD_FACTORY.addStep(git_step( "git://git.taler.net/deployment.git")) -SWITCHER_FACTORY.addStep(ShellCommand( +BUILD_FACTORY.addStep(ShellCommand( name="config", description="Generating configuration file.", descriptionDone="Configuration file generated.", command=["./config.sh"], workdir="build/buildbot", - haltOnFailure=True, - env={'BRANCH': util.Property("branch")})) + haltOnFailure=True)) -SWITCHER_FACTORY.addStep(ShellCommand( +BUILD_FACTORY.addStep(ShellCommand( name="build", description="Building inactive blue-green party.", descriptionDone="Inactive party got built.", command=["./build.sh"], workdir="build/buildbot", - haltOnFailure=True, - env={'BRANCH': util.Property("branch")})) + haltOnFailure=True)) -SWITCHER_FACTORY.addStep(ShellCommand( +BUILD_FACTORY.addStep(ShellCommand( name="keys generation and sign", description="Generating exchange keys, and auditor-sign them.", descriptionDone="Exchange keys generated, and auditor-signed.", @@ -294,7 +294,7 @@ SWITCHER_FACTORY.addStep(ShellCommand( haltOnFailure=True, env={'BRANCH': util.Property("branch")})) -SWITCHER_FACTORY.addStep(ShellCommand( +BUILD_FACTORY.addStep(ShellCommand( name="wire details sign", description="Signing exchange wire details.", descriptionDone="Exchange wire details got signed.", @@ -303,7 +303,7 @@ SWITCHER_FACTORY.addStep(ShellCommand( haltOnFailure=True, env={'BRANCH': util.Property("branch")})) -SWITCHER_FACTORY.addStep(ShellCommand( +BUILD_FACTORY.addStep(ShellCommand( name="restart services", description="Restarting inactive blue-green party.", descriptionDone="Restarting Taler.", @@ -312,16 +312,17 @@ SWITCHER_FACTORY.addStep(ShellCommand( haltOnFailure=True, env={'BRANCH': util.Property("branch")})) -SWITCHER_FACTORY.addStep(ShellCommand( +BUILD_FACTORY.addStep(ShellCommand( name="check services correctly restarted", description="Checking services are correctly restarted.", descriptionDone="All services are correctly restarted.", command=["./checks.sh"], workdir="build/buildbot", haltOnFailure=True, - env={'BRANCH': util.Property("branch")})) + env={'DEPLOYMENT': "test"})) -SWITCHER_FACTORY.addStep(ShellCommand( +SWITCH_FACTORY = util.BuildFactory() +SWITCH_FACTORY.addStep(ShellCommand( name="switch active party", description="Switch to the party which was inactive.", descriptionDone="Active party has been switched.", @@ -391,10 +392,16 @@ DEMO_SERVICES_CHECKER_BUILDER = util.BuilderConfig( workernames="demo-worker", factory=DEMO_SERVICES_CHECKER_FACTORY) +BUILDER_BUILDER = util.BuilderConfig( + name="builder-builder", + workernames=["builder-worker-green", + "builder-worker-blue"], + factory=BUILD_FACTORY) + SWITCHER_BUILDER = util.BuilderConfig( name="switcher-builder", workernames=["switcher-worker"], - factory=SWITCHER_FACTORY) + factory=SWITCH_FACTORY) SELENIUM_BUILDER = util.BuilderConfig( name="selenium-builder", @@ -414,7 +421,7 @@ WALLET_BUILDER = util.BuilderConfig( c["builders"] = [ LCOV_BUILDER, AUDITOR_BUILDER, - SWITCHER_BUILDER, + BUILDER_BUILDER, TIP_RESERVE_TOPPER_BUILDER, DEMO_SERVICES_CHECKER_BUILDER, SELENIUM_BUILDER, diff --git a/buildbot/restart.sh b/buildbot/restart.sh @@ -1,17 +1,11 @@ #!/bin/bash -DEPLOYMENT="test" +source "${HOME}/activate" +ACTIVE_COLOR="$(cat /home/test/active)" -if test "stable" = ${BRANCH}; then - DEPLOYMENT="demo" +if test "${TALER_ENV_COLOR}" = "${ACTIVE_COLOR}"; then + echo "I'm the active color, no need to compile and switch!" + exit 0 fi -active=$(sudo -u ${DEPLOYMENT} cat /home/${DEPLOYMENT}/active) -nonactive="${DEPLOYMENT}-blue" -echo "Active party: ${active}" - -if test $active = "${DEPLOYMENT}-blue"; then - nonactive="${DEPLOYMENT}-green" -fi - -sudo -u $nonactive bash -c 'cd $HOME; . activate; taler-deployment-restart' +taler-deployment-restart' diff --git a/buildbot/sign.sh b/buildbot/sign.sh @@ -1,17 +1,11 @@ #!/bin/bash -DEPLOYMENT="test" +source "${HOME}/activate" +ACTIVE_COLOR="$(cat /home/test/active)" -if test "stable" = ${BRANCH}; then - DEPLOYMENT="demo" +if test "${TALER_ENV_COLOR}" = "${ACTIVE_COLOR}"; then + echo "I'm the active color, no need to compile and switch!" + exit 0 fi -active=$(sudo -u ${DEPLOYMENT} cat /home/${DEPLOYMENT}/active) -nonactive="${DEPLOYMENT}-blue" -echo "Active party: ${active}" - -if test $active = "${DEPLOYMENT}-blue"; then - nonactive="${DEPLOYMENT}-green" -fi - -sudo -u $nonactive bash -c 'source $HOME/activate; taler-deployment-config-sign' +taler-deployment-config-sign' diff --git a/buildbot/switch.sh b/buildbot/switch.sh @@ -6,7 +6,7 @@ if test "stable" = ${BRANCH}; then DEPLOYMENT="demo" fi -active=$(sudo -u ${DEPLOYMENT} cat /home/${DEPLOYMENT}/active) +active=$(cat /home/${DEPLOYMENT}/active) nonactive="${DEPLOYMENT}-blue" echo "Active party: ${active}" diff --git a/buildbot/top_reserve.sh b/buildbot/top_reserve.sh @@ -1,5 +1,5 @@ #!/bin/bash -active=$(sudo -u test cat /home/test/active) +active=$(cat /home/test/active) sudo -u $active bash -c 'source $HOME/activate; taler-deployment-top-reserve'