Deployment to Beta (and changes)
Based off the work in https://gitlab.com/gitlab-org/gitter/webapp/merge_requests/1082
-
prod
-
prod-staging
-
beta
-
beta-staging
Todo
✔ Fix npm install
issue
See https://gitlab.com/gitlab-org/gitter/webapp/-/jobs/51921083
npm ERR! code EBADPLATFORM",
npm ERR! notsup Unsupported",
npm ERR! notsup Not compatible with your operating system or architecture: fsevents@1.1.3",
npm ERR! notsup Valid OS: darwin",
npm ERR! notsup Valid Arch: any",
npm ERR! notsup Actual OS: linux",
npm ERR! notsup Actual Arch: x64",
I fixed this by upgrading npm@2.15.9
to npm@3.10.10
$ cd /opt/gitter/gitter-webapp
$ ns-use /opt/node/v6-latest
$ /opt/node/v6-latest/bin/npm install npm@3.10.10 -g
$ /opt/node/v6-latest/bin/npm -v
3.10.10
# /opt/gitter/gitter-webapp-staging was already using `/opt/node/v6-latest` so it should be good to go with using the new npm 3
I already had tried updating to npm 3 in the ansible scripts but I suppose I need to run the playbook for that to actually work and I am not sure how/what to do there.
- https://gitlab.com/gl-infra/gitter-infrastructure/commit/f313d5a5dc76d7c300bcb1a8c3961997df0bbec8
- https://gitlab.com/gl-infra/gitter-infrastructure/commit/9d52a134c3352ec6c97716b272687b1400505bd0
✔ Configure service secrets (missing GitLab OAuth config)
ssh deployer@gitter-beta.beta.gitter
-> /var/log/upstart/gitter-web-staging-1.log
2018-03-27T19:56:59.240Z - info: Starting server/web.js
2018-03-27T19:57:01.551Z - error: Unable to log error to sentry:
2018-03-27T19:57:01.556Z - error: ----------------------------------------------------------------
2018-03-27T19:57:01.556Z - error: -- A VeryBadThing has happened.
2018-03-27T19:57:01.557Z - error: ----------------------------------------------------------------
2018-03-27T19:57:01.559Z - error: Uncaught exceptionTypeError: OAuth2Strategy requires a clientID option message=OAuth2Strategy requires a clientID option, name=TypeError
2018-03-27T19:57:01.561Z - error: TypeError: OAuth2Strategy requires a clientID option
at Strategy.OAuth2Strategy (/opt/gitter/gitter-webapp-staging/node_modules/passport-oauth2/lib/strategy.js:82:34)
at new Strategy (/opt/gitter/gitter-webapp-staging/node_modules/passport-gitlab2/lib/strategy.js:49:18)
at Object.<anonymous> (/opt/gitter/gitter-webapp-staging/server/web/strategies/gitlab.js:42:22)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/opt/gitter/gitter-webapp-staging/server/web/passport.js:10:22)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/opt/gitter/gitter-webapp-staging/server/web.js:24:1)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/opt/gitter/gitter-webapp-staging/web.js:7:1)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
2018-03-27T19:57:01.561Z - error: Uncaught exceptionTypeError: OAuth2Strategy requires a clientID option forcing shutdown
2018-03-27T19:57:01.611Z - info: Web server shutdown successfully in 2ms
I was able to get this file locally,
# On gitter-beta.beta.gitter
$ mkdir -p /home/deployer/delete-me-logs/ && cp /var/log/upstart/gitter-web-staging-1.log /home/deployer/delete-me-logs/gitter-web-staging-1-beta.log && chown deployer /home/deployer/delete-me-logs/gitter-web-staging-1-beta.log
# Locally
$ mkdir -p ~/Downloads/gitter-logs && scp deployer@gitter-beta.beta.gitter:/home/deployer/delete-me-logs/gitter-web-staging-1-beta.log ~/Downloads/gitter-logs
gitter-web-staging-1-beta.log
This happens when the service secrets aren't configured or not all necessary are set.
Normally to configure secrets, we need to do something like the following but @andrewn already took care of this when we first moved to a separate repo for secrets. And turns out this is configured here, https://gitlab.com/gl-infra/gitter-infrastructure/blob/744c0b7458e0f54ed5d65f0a7d938d842da1d652/ansible/roles/gitter/web/files/etc/init/gitter-web-2.conf#L14
eval $(/opt/gitter/secrets/webapp/env beta-staging)
...
/opt/deploy-tools/service-tree gitter-web-staging start
I looked at the environment variables of the node web.js
process to see if the secrets are being set and turns out they were
strings /proc/$(ps -ef | grep gitter-webapp-staging/web.js | grep -v grep | awk '{print $2}')/environ
But we are missing some new configuration for GitLab sign-in, introduced here, https://gitlab.com/gitlab-org/gitter/webapp/merge_requests/1076
So we need to update our secrets repo, https://gitlab.com/gl-gitter/secrets/tree/master/webapp. Added via https://gitlab.com/gl-gitter/secrets/merge_requests/2
gitlaboauth__client_id="xxx"
gitlaboauth__client_secret="xxx"
Update the secrets repo on the beta app servers
cd /opt/gitter-infrastructure/ansible/ && ansible-playbook -i beta --vault-password-file "/root/.vault_pass" playbooks/gitter/secrets.yml -vvvv