From d2ec0752727814533d074226189f5dd690ff937d Mon Sep 17 00:00:00 2001 From: Lens0021 Date: Sat, 19 Jun 2021 06:06:09 +0900 Subject: [PATCH] Weekly Deploy - 24 (#43) * Prepare analytics-credentials-file.json * Replace memory_hard_limit with memory_max * Improve comments * Bump mediawiki docker image * test: Retry to start Nomad --- .github/workflows/ci.yml | 7 ++++++ jobs-consul-test/backupbot.nomad | 6 ++--- jobs-consul-test/development/lb.nomad | 2 +- jobs-consul-test/development/mathoid.nomad | 6 ++--- jobs-consul-test/fastcgi.nomad | 20 +++++++++------ jobs-consul-test/http.nomad | 13 ++++------ jobs-consul-test/lb.nomad | 5 ++-- jobs-consul-test/mathoid.nomad | 6 ++--- jobs-consul-test/memcached.nomad | 6 ++--- jobs-consul-test/mysql.nomad | 14 +++++------ jobs-consul-test/restbase.nomad | 11 +++----- jobs/development/fastcgi.nomad | 2 +- jobs/development/http.nomad | 2 +- jobs/development/mathoid.nomad | 2 +- jobs/development/memcached.nomad | 2 +- jobs/development/mysql.nomad | 2 +- jobs/development/restbase.nomad | 2 +- jobs/fastcgi.nomad | 29 +++++++++++++++------- jobs/http.nomad | 6 ++--- jobs/mysql.nomad | 8 +++--- jobs/restbase.nomad | 6 ++--- 21 files changed, 81 insertions(+), 76 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9ed2a78..e1aa406e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,14 @@ jobs: - name: Wait for initializing... timeout-minutes: 5 run: | + TIME=0 until nomad node status > /dev/null; do + if [ $TIME -gt 30 ]; then + if [ -n "$(pidof nomad)" ]; then sudo kill "$(pidof nomad)"; fi + sudo nomad agent -dev-connect -config nomad/development.hcl &>/dev/null & + TIME=0 + fi + ((TIME+=1)) sleep 1; done; NODE_ID="$(nomad node status -self | head -1 | awk '{print $3}')" until [[ $(curl -s "http://127.0.0.1:4646/v1/node/$NODE_ID") = *"consul.version"* ]]; do diff --git a/jobs-consul-test/backupbot.nomad b/jobs-consul-test/backupbot.nomad index 8b546abb..ecdab5c8 100644 --- a/jobs-consul-test/backupbot.nomad +++ b/jobs-consul-test/backupbot.nomad @@ -41,11 +41,9 @@ job "backupbot" { } sidecar_task { - config { - memory_hard_limit = 300 - } resources { - memory = 30 + memory = 30 + memory_max = 300 } } } diff --git a/jobs-consul-test/development/lb.nomad b/jobs-consul-test/development/lb.nomad index 1affaa5c..a36f55b4 100644 --- a/jobs-consul-test/development/lb.nomad +++ b/jobs-consul-test/development/lb.nomad @@ -33,7 +33,6 @@ job "lb" { config { image = "traefik:v2.4.8" network_mode = "host" - memory_hard_limit = 500 ports = ["http", "api"] volumes = [ @@ -67,6 +66,7 @@ EOF resources { memory = 128 + memory_max = 500 } } } diff --git a/jobs-consul-test/development/mathoid.nomad b/jobs-consul-test/development/mathoid.nomad index c30b57b3..f84b8a28 100644 --- a/jobs-consul-test/development/mathoid.nomad +++ b/jobs-consul-test/development/mathoid.nomad @@ -7,11 +7,11 @@ job "mathoid" { config { image = "ghcr.io/femiwiki/mathoid:latest" - memory_hard_limit = 600 } resources { memory = 150 + memory_max = 600 } env { @@ -32,11 +32,9 @@ job "mathoid" { sidecar_service {} sidecar_task { - config { - memory_hard_limit = 500 - } resources { memory = 100 + memory_max = 500 } } } diff --git a/jobs-consul-test/fastcgi.nomad b/jobs-consul-test/fastcgi.nomad index f3c57edd..ec449164 100644 --- a/jobs-consul-test/fastcgi.nomad +++ b/jobs-consul-test/fastcgi.nomad @@ -32,6 +32,12 @@ job "fastcgi" { mode = "file" } + artifact { + source = "s3::https://femiwiki-secrets.s3-ap-northeast-1.amazonaws.com/analytics-credentials-file.json" + destination = "secrets/analytics-credentials-file.json" + mode = "file" + } + artifact { source = "https://github.com/femiwiki/nomad/raw/main/php/opcache-recommended.ini" destination = "local/opcache-recommended.ini" @@ -63,11 +69,12 @@ job "fastcgi" { } config { - image = "ghcr.io/femiwiki/mediawiki:2021-05-28T22-03-473c97b0" + image = "ghcr.io/femiwiki/mediawiki:latest" ports = ["fastcgi"] volumes = [ "secrets/secrets.php:/a/secret.php", + "secrets/analytics-credentials-file.json:/a/analytics-credentials-file.json", "local/opcache-recommended.ini:/usr/local/etc/php/conf.d/opcache-recommended.ini", "local/php.ini:/usr/local/etc/php/php.ini", "local/php-fpm.conf:/usr/local/etc/php-fpm.conf", @@ -90,12 +97,11 @@ job "fastcgi" { readonly = false }, ] - - memory_hard_limit = 800 } resources { - memory = 300 + memory = 300 + memory_max = 800 } env { @@ -150,11 +156,9 @@ job "fastcgi" { } sidecar_task { - config { - memory_hard_limit = 300 - } resources { - memory = 30 + memory = 30 + memory_max = 300 } } } diff --git a/jobs-consul-test/http.nomad b/jobs-consul-test/http.nomad index 78d8c96a..72ff3a33 100644 --- a/jobs-consul-test/http.nomad +++ b/jobs-consul-test/http.nomad @@ -12,7 +12,7 @@ job "http" { } config { - image = "ghcr.io/femiwiki/mediawiki:2021-05-28T14-01-0b1f9738" + image = "ghcr.io/femiwiki/mediawiki:latest" command = "caddy" args = ["run"] volumes = ["local/Caddyfile:/srv/femiwiki.com/Caddyfile"] @@ -34,12 +34,11 @@ job "http" { ulimit { nofile = "20000:40000" } - - memory_hard_limit = 400 } resources { - memory = 100 + memory = 100 + memory_max = 400 } env { @@ -90,11 +89,9 @@ job "http" { } sidecar_task { - config { - memory_hard_limit = 500 - } resources { - memory = 300 + memory = 300 + memory_max = 500 } } } diff --git a/jobs-consul-test/lb.nomad b/jobs-consul-test/lb.nomad index 58285f85..6fe943b1 100644 --- a/jobs-consul-test/lb.nomad +++ b/jobs-consul-test/lb.nomad @@ -56,12 +56,11 @@ job "lb" { readonly = false }, ] - - memory_hard_limit = 500 } resources { - memory = 128 + memory = 128 + memory_max = 500 } } } diff --git a/jobs-consul-test/mathoid.nomad b/jobs-consul-test/mathoid.nomad index db4118bc..2e3143c6 100644 --- a/jobs-consul-test/mathoid.nomad +++ b/jobs-consul-test/mathoid.nomad @@ -31,11 +31,9 @@ job "mathoid" { sidecar_service {} sidecar_task { - config { - memory_hard_limit = 500 - } resources { - memory = 300 + memory = 300 + memory_max = 500 } } } diff --git a/jobs-consul-test/memcached.nomad b/jobs-consul-test/memcached.nomad index 84f09b13..c3efc559 100644 --- a/jobs-consul-test/memcached.nomad +++ b/jobs-consul-test/memcached.nomad @@ -26,11 +26,9 @@ job "memcached" { sidecar_service {} sidecar_task { - config { - memory_hard_limit = 300 - } resources { - memory = 30 + memory = 30 + memory_max = 300 } } } diff --git a/jobs-consul-test/mysql.nomad b/jobs-consul-test/mysql.nomad index 19e2f8a0..d93840a9 100644 --- a/jobs-consul-test/mysql.nomad +++ b/jobs-consul-test/mysql.nomad @@ -26,13 +26,13 @@ job "mysql" { } config { - image = "mysql/mysql-server:8.0.25" - volumes = ["local/my.cnf:/etc/mysql/my.cnf"] - memory_hard_limit = 800 + image = "mysql/mysql-server:8.0.25" + volumes = ["local/my.cnf:/etc/mysql/my.cnf"] } resources { - memory = 300 + memory = 300 + memory_max = 800 } env { @@ -52,11 +52,9 @@ job "mysql" { sidecar_service {} sidecar_task { - config { - memory_hard_limit = 300 - } resources { - memory = 30 + memory = 30 + memory_max = 300 } } } diff --git a/jobs-consul-test/restbase.nomad b/jobs-consul-test/restbase.nomad index d09db428..a3a83d90 100644 --- a/jobs-consul-test/restbase.nomad +++ b/jobs-consul-test/restbase.nomad @@ -16,12 +16,11 @@ job "restbase" { readonly = false } ] - - memory_hard_limit = 400 } resources { - memory = 100 + memory = 100 + memory_max = 400 } env { @@ -58,11 +57,9 @@ job "restbase" { } sidecar_task { - config { - memory_hard_limit = 500 - } resources { - memory = 300 + memory = 300 + memory_max = 500 } } } diff --git a/jobs/development/fastcgi.nomad b/jobs/development/fastcgi.nomad index 7743c0ee..13a232cf 100644 --- a/jobs/development/fastcgi.nomad +++ b/jobs/development/fastcgi.nomad @@ -39,7 +39,6 @@ job "fastcgi" { config { image = "ghcr.io/femiwiki/mediawiki:latest" network_mode = "host" - memory_hard_limit = 600 volumes = [ "secrets/secrets.php:/a/secret.php", @@ -70,6 +69,7 @@ job "fastcgi" { resources { memory = 100 + memory_max = 600 } } } diff --git a/jobs/development/http.nomad b/jobs/development/http.nomad index 935364f2..9a0fb2ce 100644 --- a/jobs/development/http.nomad +++ b/jobs/development/http.nomad @@ -86,11 +86,11 @@ job "http" { ] network_mode = "host" - memory_hard_limit = 400 } resources { memory = 80 + memory_max = 400 } } } diff --git a/jobs/development/mathoid.nomad b/jobs/development/mathoid.nomad index 4510eacc..c142aa59 100644 --- a/jobs/development/mathoid.nomad +++ b/jobs/development/mathoid.nomad @@ -7,11 +7,11 @@ job "mathoid" { config { image = "ghcr.io/femiwiki/mathoid:latest" - memory_hard_limit = 600 } resources { memory = 150 + memory_max = 600 } env { diff --git a/jobs/development/memcached.nomad b/jobs/development/memcached.nomad index b8f5f8d6..f6307b2e 100644 --- a/jobs/development/memcached.nomad +++ b/jobs/development/memcached.nomad @@ -7,11 +7,11 @@ job "memcached" { config { image = "memcached:1-alpine" - memory_hard_limit = 240 } resources { memory = 60 + memory_max = 240 } } diff --git a/jobs/development/mysql.nomad b/jobs/development/mysql.nomad index 846dde06..d470e991 100644 --- a/jobs/development/mysql.nomad +++ b/jobs/development/mysql.nomad @@ -25,7 +25,6 @@ EOF config { image = "mysql/mysql-server:8.0" - memory_hard_limit = 1000 volumes = ["local/my.cnf:/etc/mysql/my.cnf"] mounts = [ @@ -40,6 +39,7 @@ EOF resources { memory = 500 + memory_max = 1000 } env { diff --git a/jobs/development/restbase.nomad b/jobs/development/restbase.nomad index b25caddd..922c5c52 100644 --- a/jobs/development/restbase.nomad +++ b/jobs/development/restbase.nomad @@ -8,11 +8,11 @@ job "restbase" { config { image = "ghcr.io/femiwiki/restbase:latest" network_mode = "host" - memory_hard_limit = 400 } resources { memory = 100 + memory_max = 400 } env { diff --git a/jobs/fastcgi.nomad b/jobs/fastcgi.nomad index 0740d9a3..e29d8365 100644 --- a/jobs/fastcgi.nomad +++ b/jobs/fastcgi.nomad @@ -32,6 +32,12 @@ job "fastcgi" { mode = "file" } + artifact { + source = "s3::https://femiwiki-secrets.s3-ap-northeast-1.amazonaws.com/analytics-credentials-file.json" + destination = "secrets/analytics-credentials-file.json" + mode = "file" + } + artifact { source = "https://github.com/femiwiki/nomad/raw/main/php/opcache-recommended.ini" destination = "local/opcache-recommended.ini" @@ -69,7 +75,7 @@ job "fastcgi" { } config { - image = "ghcr.io/femiwiki/mediawiki:2021-06-11T14-08-16638bc2" + image = "ghcr.io/femiwiki/mediawiki:2021-06-18T04-57-20822934" volumes = [ "local/opcache-recommended.ini:/usr/local/etc/php/conf.d/opcache-recommended.ini", @@ -77,6 +83,7 @@ job "fastcgi" { "local/php-fpm.conf:/usr/local/etc/php-fpm.conf", "local/www.conf:/usr/local/etc/php-fpm.d/www.conf", "secrets/secrets.php:/a/secret.php", + "secrets/analytics-credentials-file.json:/a/analytics-credentials-file.json", # Overwrite the default Hotfix.php provided by femiwiki/mediawiki "local/Hotfix.php:/a/Hotfix.php", ] @@ -96,12 +103,12 @@ job "fastcgi" { } ] - network_mode = "host" - memory_hard_limit = 800 + network_mode = "host" } resources { - memory = 400 + memory = 400 + memory_max = 800 } env { @@ -111,7 +118,7 @@ job "fastcgi" { NOMAD_UPSTREAM_ADDR_mathoid = "127.0.0.1:10044" MEDIAWIKI_SKIP_INSTALL = "1" MEDIAWIKI_SKIP_IMPORT_SITES = "1" - MEDIAWIKI_SKIP_UPDATE = "1" + # MEDIAWIKI_SKIP_UPDATE = "1" } } } @@ -132,14 +139,18 @@ variable "hotfix" { type = string default = <