Граф коммитов

58 Коммитов

Автор SHA1 Сообщение Дата
Ed Morley 5a1b3d60ac
Bug 1445469 - Update to geckodriver v0.20.0 (#3339)
https://github.com/mozilla/geckodriver/releases/tag/v0.20.0
2018-03-13 23:23:33 +00:00
Ed Morley b7ec45cd3e
Bug 1428919 - Vagrant: Update to latest Bento image (#3202)
To pick up the newer kernel/security updates. Only takes effect when
people destroy/recreate their VM, so also adds a `dist-upgrade` to
upgrade existing boxes. (The older Bento box had a broken kernel
config so `dist-upgrade` can't upgrade the kernel, but it's better
than nothing.)

Also switches the Hyper-V provider to the Bento images for parity,
since Bento now create Hyper-V variants too.

The `box` name cannot be factored out of the provider blocks due to:
https://github.com/hashicorp/vagrant/issues/9452
2018-02-12 16:50:17 +00:00
Ed Morley 4d45f3cf55 Bug 1384518 - Vagrant: Remove memcached server and libraries
Since memcached server and the client headers are now unused.

Whilst the `zlib1g-dev` package is no longer needed by pylibmc, it's
still required as a sub-dependency of `libmysqlclient-dev`, so has
deliberately not been added to the `apt-get purge` cleanup step.
2018-01-21 14:41:35 +00:00
Ed Morley deb1fc86b7 Bug 1384518 - Switch from Memcached to Redis
Since:
* Redis has additional features we need (eg for bug 1409679)
* the Redis server, python client and Django backend are more
  actively maintained (so have persistent connections/pooling that
  actually works, which gives a big perf win)
* we can use Heroku's own Redis addon rather than relying on a
  third-party's (to hopefully prevent a repeat of the certificate
  expiration downtime)

This commit:
* Switches pylibmc/django-pylibmc to redis-py/django-redis, and
  configures the new backend according to:
  http://niwinz.github.io/django-redis/latest/
  https://github.com/andymccurdy/redis-py
* Uses redis-py's native support for TLS to connect to the Heroku
  Redis server's stunnel port directly, avoiding the complexity of
  using a buildpack to create an stunnel between the dyno and server:
  https://devcenter.heroku.com/articles/securing-heroku-redis#connecting-directly-to-stunnel
* Uses explicit `REDIS_URL` values on Travis/Vagrant rather than
  relying on the django-environ `default` value (for parity with
  how we configure `DATABASE_URL` and others).
* Removes the pylibmc connection-closing workaround from `wsgi.py`.

Note: Whilst the Heroku docs suggest using `django-redis-cache`, it's
not as actively maintained, so we're using `django-redis` instead:
https://devcenter.heroku.com/articles/heroku-redis
https://github.com/niwinz/django-redis
https://github.com/sebleier/django-redis-cache

Before this is merged, Heroku Redis instances will need to be created
for stage/production (prototype done) - likely on plan `premium-3`:
https://elements.heroku.com/addons/heroku-redis

We'll also need to pick an eviction policy:
https://devcenter.heroku.com/articles/heroku-redis#maxmemory-policy

Once deployed, the `memcachier-tls-buildpack` buildpack will no longer
be required and can be removed from prototype/stage/prod, along with
the `TREEHERDER_MEMCACHED` environment variable and Memcachier addon.
2018-01-21 14:41:35 +00:00
Ed Morley d9909d5fa2 Bug 1384518 - Add a Redis server instance to Vagrant/Travis
In preparation for later commits, this installs `redis-server` in
the Vagrant environment, and starts the pre-installed (but stopped
by default) `redis-server` on Travis:
https://docs.travis-ci.com/user/database-setup/#Redis

Production/stage/prototype will use Heroku's own Redis add-on:
https://elements.heroku.com/addons/heroku-redis
2018-01-21 14:41:35 +00:00
Ed Morley 56697adb1f Bug 1384518 - Vagrant: Simplify .profile helper functions
Uses our custom `clear_cache` Django management command instead of
restarting memcached, since (a) for memcached has the same effect,
(b) will continue to work even after we switch to Redis (which instead
persists cache contents across server restarts).

Removes the `threstartmemcached` command since IMO it's no simpler
than just running `./manage.py clear_cache` on its own.
2018-01-17 11:08:39 +00:00
Ed Morley f7ac7ba3f5
Vagrant: Remove no longer needed g++ package (#3125)
Since Brotli now ships as a wheel, so doesn't need g++ to build.
2018-01-11 11:43:36 +00:00
Ed Morley 75606492dd
Remove references to previously removed .profile helper aliases (#3123)
The `tabname` and `thlogsdelete` functions were removed in #1995.
2018-01-11 11:21:41 +00:00
Ed Morley 076083373c
Vagrant: Remove redundant environment variables (#3051)
* `ENABLE_LOCAL_SETTINGS_FILE` is no longer references anywhere.
* `GRAPHQL` now defaults to `True`, so doesn't need to be overridden.
2017-12-20 14:04:26 +00:00
Ed Morley e59d68fc76
Vagrant: Update shellcheck from 0.4.6 to 0.4.7 (#3035)
Passes locally even given the newly added checks:
https://github.com/koalaman/shellcheck/blob/master/CHANGELOG.md#v047---2017-12-08
2017-12-15 17:14:37 -06:00
Ed Morley 12a7c357cf
Bug 1421073 - Vagrant: Fix networking on non-Windows platforms (#3015)
On platforms that are not Windows, the Vagrantfile enables a second
virtual network adapter to allow NFS to work. However this breaks
the fix in bug 1417099, since it only expected one interface to be
returned by the grepped `ip` output. We could have adjusted that fix
to instead iterate through the results, however it's easier to just
use a wildcard with `iptables` instead, since we know all ethernet
adapters start with the letter `e`.
2017-12-05 17:11:41 +00:00
Ed Morley 23ac51fe3b
Bug 1418982 - Vagrant: Hide expected warnings during provision (#2964)
To reduce the potential for contributors thinking the provision
didn't complete successfully.
2017-11-22 00:27:38 +00:00
Ed Morley 3f5ef6b352 Bug 1418956 - Set yarn's no-bin-links option via .yarnrc
To save having to pass it each time when using `yarn {install,add}`.
2017-11-20 18:59:26 +00:00
Ed Morley 69f07fa84e Bug 1416257 - Disable yarn strict engines mode using .yarnrc
As of yarn 1.0+ if the version of node or yarn doesn't match that
specified in `package.json`, yarn commands will fail to run and
complain about incompatible versions. Unfortunately the error message
doesn't really make it clear that the user has the wrong version
installed, and instead gives the impression something is broken with
Treeherder. In addition, much of the time the exact version isn't
important, so the user doesn't need to go to the trouble of changing
their node installation.

As such, we just disable the yarn engines check for now.
2017-11-20 18:59:26 +00:00
Ed Morley c9500cf3d2
Bug 1417099 - Vagrant: Fix networking when using latest Bento images (#2945)
The bento image has renamed the network interface from `enp0s3` back
to `eth0`, effectively reverting the upstream Ubuntu 16.04 "predictable
network interface names" feature. We now have to calculate the name
dynamically, since we don't know which version of the bento image
will be installed locally when people use the Treeherder Vagrant
environment.
2017-11-14 19:14:20 +00:00
Dave Hunt 9fd3c72241
Bug 1340305 - Allow Selenium tests to be run locally 2017-11-09 12:55:25 +00:00
Ed Morley d47a3e7a5f
Bug 1414255 - Vagrant: Use alternative fix for shellcheck SC2164 (#2918)
Since the `.profile` script is sourced in the login shell, so using
strict mode can cause the shell to exit and so `vagrant ssh` to not
work. Instead we fix the SC2164 using the method here:
https://github.com/koalaman/shellcheck/wiki/SC2164
2017-11-06 13:07:28 +00:00
Ed Morley 9a6c79745f Bug 1414255 - Use shellcheck to validate bash scripts
https://github.com/koalaman/shellcheck

Travis has shellcheck v0.4.6 pre-installed, so we only need to install
it in the Vagrant environment.
2017-11-05 20:53:29 +00:00
Ed Morley ee002acf00 Bug 1414255 - Fix shellcheck warning about useless cat invocation
`SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.`

See:
https://github.com/koalaman/shellcheck/wiki/SC2002
2017-11-05 20:53:29 +00:00
Ed Morley be843a8837 Bug 1414255 - Fix shellcheck warnings about sourced files
```
SC1090: Can't follow non-constant source. Use a directive to specify location.
SC1091: Not following: /etc/profile.d/treeherder.sh was not specified as input (see shellcheck -x).
```

See:
https://github.com/koalaman/shellcheck/wiki/SC1090
https://github.com/koalaman/shellcheck/wiki/SC1091
2017-11-05 20:53:29 +00:00
Ed Morley 37b2c9855e Bug 1414255 - Fix shellcheck warnings about missing quotes
`SC2086: Double quote to prevent globbing and word splitting`

See:
https://github.com/koalaman/shellcheck/wiki/SC2086
2017-11-05 20:53:29 +00:00
Ed Morley 934c6a2ab9 Bug 1414255 - Enable bash 'strict mode' in all shell scripts
This makes some of the error checking in `runtest.sh` redundant.
The shebangs have also been made more consistent.

See:
http://redsymbol.net/articles/unofficial-bash-strict-mode/
2017-11-05 20:53:29 +00:00
Ed Morley 321c979e93 Bug 1408683 - Vagrant: Don't install Git (#2835)
Since in most cases people will use it from the host anyway, and if
they don't it can lead to committing changes under the author
`vagrant <vagrant@vagrant.vm>`.
2017-10-17 18:43:53 +02:00
Ed Morley fc75f93a54 Bug 1399281 - Vagrant: Use --ignore-engines with yarn install
To prevent errors when Vagrant provisioning after a new nodejs
version is released, due to version mismatch between package.json
(used by Heroku) and the APT package used by Vagrant. The other
option is pinning the version in Vagrant too, however we might as
well wait until the Docker based development environment where
state management/invalidation is simpler.
2017-09-13 22:58:28 +01:00
Ed Morley 14e43640fe Bug 1392546 - Travis/Vagrant: Set innodb_flush_log_at_trx_commit=0
By default MySQL#s InnoDB flushes to disk after every transaction to
reduce the chance of data loss in the case of a crash. During testing
and development this is not necessary and only serves to limit I/O
throughput. By switching to mode `0` (flushing every second), test
runtimes are reduced by 20-30%.

See:
https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit
2017-08-23 09:39:22 +01:00
Ed Morley 049f29d845 Bug 1392546 - Travis/Vagrant: Disable MySQL slow query log
Since it's mostly pointless locally, given that the DB is rarely
large enough to cause a slow query and that it's unlikely that devs
check the logs anyway.
2017-08-23 09:39:22 +01:00
Ed Morley 7c5b26dac1 Bug 1392546 - Travis/Vagrant: Remove bind-address from mysql.cnf
Since as of bug 1362443 connections can still be made to the DB from
outside Vagrant even if `bind-address` is not overridden.
2017-08-23 09:39:22 +01:00
Ed Morley a26144306d Bug 1390598 - Upgrade to nodejs 8
This speeds up yarn build by 22% and yarn test by 14%, which helps
with Heroku deploy times.

Changelog:
https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V7.md#7.10.1
https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V8.md#8.4.0
2017-08-18 11:34:31 +01:00
Ed Morley 1fee79052b Bug 1390573 - Vagrant: Remove .pyc files during provision
To prevent confusing pytest `ImportMismatchError` exceptions if the
paths hardcoded in pyc files (which are git-ignored) leftover from
the past, don't match the paths used now.
2017-08-15 18:54:04 +01:00
Ed Morley 729183f41f Bug 1390573 - Vagrant: Move the cleanup step earlier in provision
To reduce the risk that one of the commands we run is broken by things
that need cleaning up (eg pyc files). An unnecessary `|| true` has also
been removed from the `rm -f` moved command.
2017-08-15 18:54:04 +01:00
Ed Morley 5c4fc47b29 Bug 1387266 - Vagrant: Remove Python archive workaround
Since the archives have now been updated to no long include the
unwanted additional packages:
https://github.com/heroku/heroku-buildpack-python/issues/379#issuecomment-319223312
2017-08-04 00:28:32 +01:00
Ed Morley e63c8e7f2f Bug 1378361 - Update Elasticsearch from 5.3.1 to 5.5.0
This updates the version used in Vagrant and on Travis to the latest
release. The Heroku addon version will be updated separately to match.

Changes between the two versions:
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/release-notes-5.3.2.html
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/release-notes-5.3.3.html
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/release-notes-5.4.0.html
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/release-notes-5.4.1.html
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/release-notes-5.4.2.html
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/release-notes-5.4.3.html
https://www.elastic.co/guide/en/elasticsearch/reference/5.5/release-notes-5.5.0.html
2017-07-14 13:10:00 +01:00
Ed Morley 225c772e38 Bug 1378433 - Stop vendoring libmysqlclient in Vagrant/Travis
Now that we're using MySQL 5.7 server, there is no longer a conflict
between our desired choice of client library (which had to be 5.7 to
avoid security vulnerabilities) and the server version.

The library is still vendored on Heroku for now (in `bin/pre_compile`),
but that can stop too, once we switch to the Heroku-16 stack which is
based on Ubuntu 16.04 (bug 1365567).
2017-07-07 18:56:12 +01:00
Ed Morley fd75e9ae15 Bug 1378433 - Update to MySQL 5.7 in Vagrant/Travis
The Vagrant environment is running Ubuntu 16.04, which has a native
mysql-server-5.7 package available, so doesn't need a custom APT
repository to be set.

Travis is still on Ubuntu 14.04 (since they don't offer 16.04 yet),
so has to use the upstream mysql.com repository instead.

In the future I'll be switching both Travis and local development to
use the same Docker images to avoid these kind of differences.

After this lands, we'll want to open a PR against the Terraform configs
to switch the treeherder-dev RDS instance to MySQL 5.7, before doing
the same for stage/prod.
2017-07-07 18:56:12 +01:00
Ed Morley de7b3973c3 Bug 1363444 - Vagrant: Update to Ubuntu 16.04
At some point soon we'll want to switch Heroku stage/production to
their new Heroku-16 (Ubuntu 16.04) stack, so it makes sense to trial
it locally first. Their Heroku-16 docker image will make switching
to docker simpler too.

Notable changes to the provision steps:
* We're using the Bento boxes rather than the 'official' Canonical
  ones, at the recommendation of Vagrant:
  https://www.vagrantup.com/docs/boxes.html#official-boxes
* openjdk-8-jre-headless is now available from the ubuntu.com
  repository, so doesn't require a PPA.
* There isn't an official mysql-server-5.6 package (only 5.7+), so
  we have to start using a PPA.
* Services must now be managed using systemd rather than SysV init.
* The `eth0` network interface has changed name:
  https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
* The `vendor-libmysqlclient.sh` script will still be run on Ubuntu
  14.04 on Travis/Heroku for now, so has to be compatible with both.
* The previous temporary cleanup steps can be removed since the
  vagrant destroy means a clean slate.
2017-05-10 19:52:18 +01:00
Ed Morley 1e9113c651 Bug 1363333 - Vagrant/Travis: Update pip to 9.0.1
https://pip.pypa.io/en/stable/news/
2017-05-09 12:56:56 +01:00
Ed Morley d604044192 Bug 1363333 - Vagrant: Switch from Python PPA to Heroku binaries
Since the third-party PPA is no longer maintained, and doesn't have
Python 2.7.13 which is what is being used on Heroku. Instead we copy
the Heroku Python buildpack installation method for greater parity:
18c404f72d/bin/steps/python
2017-05-09 12:56:36 +01:00
Ed Morley f9d1f89a9b Bug 1363333 - Vagrant: Set PATH instead of activating virtualenv
Adds the virtualenv directory to `PATH` in `env.sh`, to save having
to activate the virtualenv (which is about to be removed) or set
`PATH` in each of the wrapper bin scripts.
2017-05-09 12:44:19 +01:00
Ed Morley 4735e9d434 Bug 1362443 - Vagrant: Replace varnish with iptables rule
By default webservers like Django's runserver, gunicorn or the
Webpack devserver only bind to the loopback adapter (127.0.0.1) and
so are not accessible from outside the Vagrant / virtualbox VM,
since port forwarding only forwards traffic to the non-loopback
adapters.

Previously varnish (which listened on `0.0.0.0`) was reverse
proxying traffic to runserver/gunicorn, however we need to now do so
for webpack-dev-server on another port too. Doing both with varnish
adds complexity, and we don't actually need any of varnish's other
features, so ideally want to stop using it.

Rather than having to override each webserver to bind to all
adapters (using the IP `0.0.0.0`), it's possible to forward traffic
to the loopback adapter using iptables NAT PREROUTING rules. This
is still secure so long as the Vagrantfile port forwarding uses a
`host_ip` of `127.0.0.1`. To prevent this "Martian packet" traffic
from being blocked, `route_localnet` must also be set to `1`. See:
https://unix.stackexchange.com/questions/111433/iptables-redirect-outside-requests-to-127-0-0-1

By default neither sysctl or iptables settings are persisted across
reboots, and fixing that requires more complexity (eg installing the
iptables-persistent package and handling config changes during
provision). As such, it's just easier to re-run the commands on each
login since they take <30ms.
2017-05-06 17:32:41 +01:00
Ed Morley 18e8971532 Bug 1340554 - Update from Elasticsearch 2.x to 5.x
* ES 5.x now requires JDK 8, and Ubuntu 14.04 only ships with openjdk 7,
  so a third party PPA must be used in Vagrant:
  https://launchpad.net/~openjdk-r/+archive/ubuntu/ppa
* ES 5.x changed the way it manages the heap size, such that:
  - The variables for controlling it have changed (now set via eg
    `ES_JAVA_OPTS="-Xms1g -Xmx1g"` or in the jvm.options file). See:
    https://www.elastic.co/guide/en/elasticsearch/reference/5.2/heap-size.html
  - The default heap size has increased from ~(min:256MB, max:1GB) to
    (min: 2GB, max: 2GB) which causes OOM in the VM, unless either
    lowered back down or the VM RAM increased.
* The Python ES clients must be updated to the latest releases:
  https://elasticsearch-py.readthedocs.io/en/master/#compatibility
* The previous test failures were fixed in #2403.
* The Vagrant provision now also waits for Elasticsearch to be ready
  before trying to run the Django migrations, since Elasticsearch can
  take a while to start (and always has). This prevents failures when
  the pip/yarn install steps are no-ops (when already up to date),
  causing the Django migration to run immediately after the ES install
  step.
2017-04-21 14:38:00 +01:00
Ed Morley a3eb8b5313 Bug 1353807 - Remove celerybeat-schedule during provision
Since it saves having to document the troubleshooting step.
2017-04-19 00:49:15 +01:00
Ed Morley 2dc7f227bb Bug 1357491 - Update Vagrant/Travis Elasticsearch from 2.3.5 to 2.4.4
For parity with that already running on Heroku prototype.
2017-04-19 00:47:32 +01:00
Ed Morley a9e294704d Bug 1318295 - Vagrant: Remove the puppet provisioner
Since it's now a no-op.
2017-03-21 22:48:51 +00:00
Ed Morley fb4e3892e1 Bug 1318295 - Vagrant: Move Django setup tasks to shell provisioner 2017-03-21 22:48:51 +00:00
Ed Morley be123f862b Bug 1318295 - Vagrant: Move profile/env setup to shell provisioner 2017-03-21 22:48:51 +00:00
Ed Morley 0d649ead54 Bug 1318295 - Vagrant: Move yarn install to shell provisioner 2017-03-21 22:48:51 +00:00
Ed Morley a7b3201081 Bug 1318295 - Vagrant: Move pip install to shell provisioner
The pip output is pretty noisy by default and `-q` is much too quiet.
As such the filtering with `sed` is about all we can do (and is what the
Heroku Python buildpack does too).
2017-03-21 22:48:51 +00:00
Ed Morley a9729e7cc1 Bug 1318295 - Vagrant: Move libmysqlclient install to shell provisioner
The vendor script outputs its own status message, so none required in
`vagrant/setup.sh`.
2017-03-21 22:48:51 +00:00
Ed Morley 162975c420 Bug 1318295 - Vagrant: Move virtualenv creation to shell provisioner 2017-03-21 22:48:51 +00:00
Ed Morley 53bec2df44 Bug 1318295 - Vagrant: Move virtualenv install to shell provisioner
In a later PR I'm going to be removing the virtualenv and global
Python/pip installs entirely (in favour of vendoring the same Python
binary that Heroku uses), which will simplify the steps being added here
and in the next few commits.
2017-03-21 22:48:51 +00:00