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

113 Коммитов

Автор SHA1 Сообщение Дата
Ed Morley 23c4a5ea14 Bug 1258700 - Generate Brotli-compressed versions of static files
WhiteNoise 3.0 now supports serving Brotli-compressed files to browsers
whose `Accept-Encoding` includes `br`. Note: Both Firefox and Chrome
only support Brotli over HTTPS.

To take advantage of this, the Brotli package just needs to be available
when the compression tool (`python -m whitenoise.compress`) is run. See:
http://whitenoise.evans.io/en/latest/changelog.html#brotli-compression-support
http://whitenoise.evans.io/en/latest/django.html#brotli-compression

The WhiteNoise docs say to use an unofficial PyPI package (brotlipy),
however this has a dependency on libffi (via cffi) and the official repo
now has it's own Python wrapper that does not. As such, this commit
instead uses the official Brotli package from GitHub, whilst we wait for
the official PyPI release (https://github.com/google/brotli/issues/72).

The Brotli install works fine on stage/prod/Heroku/Travis. The Vagrant
environment was missing g++, which is now installed during provision.
2016-03-30 13:00:23 +02:00
Ed Morley 513fc6a7a7 Bug 1258676 - Update to virtualenv 15.0.1
Since virtualenv 15.0.1 includes pip 8.1.1:
https://virtualenv.pypa.io/en/latest/changes.html
https://github.com/pypa/virtualenv/compare/15.0.0...15.0.1
2016-03-22 12:40:45 +00:00
Ed Morley fd76450879 Bug 1254961 - Update to pip 8.1.0
To pick up require-hashes improvements, amongst other things:
https://pip.pypa.io/en/stable/news/
https://github.com/pypa/pip/compare/8.0.2...8.1.0

The Vagrant environment's virtualenv has been updated to 15.0.0, since
that includes pip 8.1.0:
https://virtualenv.pypa.io/en/latest/changes.html
https://github.com/pypa/virtualenv/compare/14.0.1...15.0.0
2016-03-09 18:04:54 +00:00
Ed Morley a83f930296 Bug 1213230 - Use pip 8's require-hashes feature instead of peep
As of pip 8, peep has now been integrated into pip.

Migrating from peep to this native feature has several advantages:
* It avoids the complexity/learning curve of using a wrapper around pip.
* It means we do not need to fork the official Heroku Python buildpack
  (which handles pip installation of requirements files) in order to use
  hash verification on Heroku. (Once the buildpack updates to pip 8.)
* Omitted sub-dependencies result in install-time errors rather than
  the user discovering omissions at run-time.
* pip's native caching is used, and all packages are installed in one
  pip invocation, so it's significantly faster.
* It has better handling of errors and corner cases.

Key facts about the native feature:
* hash-checking mode is enabled if at least one hash is found in the
  requirements files passed to pip, or can be force enabled by passing
  `--requires-hashes` when running `pip install`.
* Once enabled, hash-checking mode enforces that all packages:
  - are pinned to a specific version
  - have hashes listed
  - have all sub-dependencies specified
* Older versions of pip will error out if either `--require-hashes` or
  the requirements file `--hash` syntax is used, meaning it's not
  possible to accidentally lose hash-checking protection if the pip used
  is older than expected.

For more details, see:
https://pip.pypa.io/en/stable/user_guide/#hash-checking-mode
https://pip.pypa.io/en/stable/reference/pip_install/#hash-checking-mode

The pip version on Travis and in the Vagrant virtualenv has been updated
to 8.0.2 in bug 1241144, and the stage/prod virtualenv in bug 1241519.
The Heroku Python buildpack pip was updated in bug 1241909.

The requirements files hashes were ported using `peep port`, and then
comments/URLs re-added by hand.
2016-02-15 12:06:17 +00:00
Ed Morley 1dc1f7fee5 Bug 1182043 - Use pylibmc instead of python-memcached
We're already using pylibmc on Heroku, since we need its SASL
authentication support. However we were still using python-memcached on
Vagrant, Travis, stage & prod.

To reduce the number of simultaneous changes when we migrate to Heroku,
and to ensure at that point we're testing what we ship, this switches us
to pylibmc pre-emptively for all environments.

Django does have a native pylibmc backend [1], however it doesn't
support SASL authentication, so we have to use the custom django-pylibmc
backend instead [2], which we choose to use everywhere (even though only
Heroku's memcache instances require auth) for consistency.

Installing pylibmc requires libmemcached-dev, which is installed by
default on Travis, has just been installed on stage/prod (bug 1243767),
and as of this change, is now installed in the Vagrant environment too.

The comment mentioning that pylibmc must be present in the root
requirements.txt file no longer applies, since the Python buildpack now
uses pip-grep (rather than regex) to determine whether it is in the
requirements files [3], and so handles included requirements files too.
Example: https://emorley.pastebin.mozilla.org/8858007

I'll be checking for any changes in performance when this is deployed,
however if anything I expect it to be faster since it's not pure Python.

[1] https://github.com/django/django/blob/1.8.7/django/core/cache/backends/memcached.py#L171
[2] https://github.com/django-pylibmc/django-pylibmc/blob/master/django_pylibmc/memcached.py
[3] https://github.com/heroku/heroku-buildpack-python/blob/v75/bin/steps/pylibmc#L22
2016-02-05 17:35:57 +00:00
Ed Morley 5f48f427f9 Bug 1244142 - Vagrant: Remove unnecessary package install/updates
Removes the gcc and libxml2-dev entries.

The gcc entry is a no-op, since no newer version is available for Ubuntu
14.04. It's not clear what previously required libxml2-dev, however it
was introduced in a commit that added AWS support for the now
decommissioned AWS dev environment. Either way the provision succeeds
without it now.
2016-01-29 16:16:48 +00:00
Ed Morley 0584b823c1 Bug 1241144 - Vagrant: Update from virtualenv 14.0.0 to 14.0.1
To update the bundled pip from 8.0.0 to 8.0.2.

https://virtualenv.pypa.io/en/latest/changes.html
2016-01-22 12:00:51 +00:00
Ed Morley 3e99e0097c Bug 1241144 - Vagrant: Update from virtualenv v13.1.2 to v14.0.0
To update the bundled pip from v7.1.2 to v8.0.0.

https://virtualenv.pypa.io/en/latest/changes.html
2016-01-21 11:12:06 +00:00
Ed Morley 7241e5c8c5 Bug 1240523 - Vagrant: Remove distro-specific code & deadcode
We only ever run this on Ubuntu (and the Heroku containers run Ubuntu
too) so let's drop support for other distros.
2016-01-18 16:50:54 +00:00
Ed Morley c8911cf4ae Bug 1240523 - Vagrant: Don't run add-apt-repository on every provision
Once the PPA has been added to the sources list there is no need to
run it again.
2016-01-18 16:50:54 +00:00
Ed Morley b7a93c02b3 Bug 1240523 - Vagrant: Don't update the varnish port on every provision
Also gives the exec command a more friendly name (instead of combining
the name and command) and removes the unnecessary multi-distro handling.
2016-01-18 16:50:54 +00:00
Ed Morley 321fafa5a2 Bug 1230104 - Vagrant: Update virtualenv from v12.1.1 to v13.1.2
Now that peep is compatible with pip v7.x, we can update to the latest
virtualenv that includes pip v7.1.2.

https://virtualenv.readthedocs.org/en/latest/changes.html
https://github.com/pypa/virtualenv/compare/12.1.1...13.1.2
2015-12-03 11:05:38 +00:00
Ed Morley cd353f5e3c Bug 1160561 - Add support for setting BROKER_URL via the environment
The individual RABBITMQ_* variables are never used on their own, so it
makes more sense to switch to a URL variable that combines all of them.

Travis/Vagrant have also had BROKER URL explicitly set, since we're
generally moving away from having testing defaults set in settings.py.

Once stage/prod have BROKER_URL set, we can remove the fallback to the
old variable names, and also remove defaults entirely, making missing
settings fail fast.
2015-11-25 21:48:15 +00:00
Ed Morley 5fc4a1a8b9 Bug 1160561 - Remove unnecessary DEBUG define in local settings file
Now that we're using django-environ's env.bool() in settings.py, the
value of TREEHERDER_DEBUG set in the Vagrant environment is correctly
picked up, so the local settings file DEBUG define is unnecessary.
2015-11-25 21:48:13 +00:00
Cameron Dawson 86b40997e6 Bug 1221516 - Adds command to get vagrant databases and env back to a clean state
This will empty all the per-repo databases, empty all the refdata and
then clear all the rabbitmq queues.
2015-11-04 13:44:48 +00:00
Mauro Doglio 078f5902d8 Bug 1193836 - use `--noinput` on migrate
This is a followup of 829cf22bc4
2015-10-27 12:05:03 +00:00
Mauro Doglio 829cf22bc4 Bug 1193836 - Update vm provisioning
This patch replaces the use of init_master_db with django `migrate`
and `load_initial_data` commands.
2015-10-27 11:19:17 +00:00
Ed Morley 3ddf626c9c Bug 1217374 - Output hawkrest WARNINGs to help debug hawk auth problems
This means rather than just returning this to the client:
'{"detail":"Hawk authentication failed"}'

We'll output more information to the stage/prod/Vagrant console and thus
logs. eg:

WARNING [hawkrest:81] access denied: MacMismatch: MACs do not match;
ours: 8HqvrjA7MO0CmJ3c6Ij2VfEuZxkchEL+pOL6Cw7At2c=; theirs:
CyDv9vnmqP6yGqT+LknMA+FOwJvSLATJwvVgG0OTl8A=

Thanks to the log.warn() here:
https://github.com/kumar303/hawkrest/blob/0.0.8/hawkrest/__init__.py#L80

I've removed the log level set on the console handler, since I think
it's clearer to set them on the loggers themselves, but it's not
entirely clear what Django logging best practices are, since the Django
docs are not very specific.
2015-10-22 15:21:03 +01:00
Ed Morley 8ae9071901 Bug 1197186 - Move settings to treeherder/config/
Since they're not specific to the Django app 'webapp'.

Whilst we're there, the local & example settings files have been
renamed. In the future I'd like to combine settings_local.example.py
with puppet/files/treeherder/local.vagrant.py, but I'll do that in
another bug.
2015-10-08 19:59:46 +01:00
Ed Morley d9bd20efd1 Bug 1212822 - Only load local.py in the Vagrant environment
Ideally we'd remove local.py entirely, in favour of environment
variables. However at least for now, it's still needed for setting the
logging preferences/enabling debugging apps for the Vagrant environment.
As such, it's being kept but disabled everywhere other than for local
development.

The stage/prod local.py files have been vetted, and (a) the contents
confirmed to match that in the environment, and (b) all affected
settings in base.py checked to ensure they read the correct environment
variable. Heroku doesn't have a local.py. As such, this should be a
no-op other than locally, where a Vagrant provision will be required.
2015-10-08 13:42:58 +01:00
Mauro Doglio be64542d11 Bug 1209555 - switch etl requests to hawk
I added a create_credentials command to help setting up the initial
development environment. The puppet setup now creates a new user and set
it as the owner of the treeherder-etl credentials.
2015-10-08 13:11:54 +01:00
Cameron Dawson b0b5460441 Bug 1207403 - don't replace existing local.py on vagrant 2015-09-24 09:11:53 -07:00
Mauro Doglio 04836704f0 Bug 1204918 - upgrade to mysql 5.6 for local development 2015-09-15 16:17:48 +01:00
Ed Morley ad3dc73715 Bug 1199179 - Remove default Django SECRET_KEY
Previously if TREEHERDER_DJANGO_SECRET_KEY was not set, we'd silently
fall back to a default value for SECRET_KEY, meaning we wouldn't realise
we were using an insecure key on a live deployment instance.

With this change, TREEHERDER_DJANGO_SECRET_KEY being missing from the
environment is fatal, resulting in:
"ImproperlyConfigured: The SECRET_KEY setting must not be empty."
2015-08-28 10:03:15 +01:00
William Lachance cc78bb50ea Bug 1198502 - Add bash aliases for restarting rabbitmq and memcached 2015-08-25 18:17:56 -04:00
Ed Morley 90ba77e596 Bug 1192801 - Remove per-file MPL boilerplate since it's unnecessary
The MPL 2.0 terms state that as long as a LICENSE file is present, the
per-file header text is not required. See "Exhibit A" at the end of:
https://www.mozilla.org/MPL/2.0/
2015-08-18 23:32:11 +01:00
Ed Morley f9ee81d999 Bug 1169944 - Always install the New Relic package, not just on prod
For bug 1124278, we're going to want to sprinkle new relic annotations
around the codebase, so by always installing it, we save having to stub
these out in development/on Travis. It also seems wise to have prod
running as close to the same packages as in development.

Since NEW_RELIC_LICENSE_KEY isn't set locally, plus
NEW_RELIC_DEVELOPER_MODE is set to true, the New Relic agent doesn't
submit anything. See:
https://docs.newrelic.com/docs/agents/python-agent/installation-configuration/python-agent-configuration#developer_mode
2015-08-11 23:23:26 +01:00
Ed Morley f92065534a Bug 1175432 - Make it more obvious if DATABASE_URL is not set
Removes the default value for DATABASE_URL and DATABASE_URL_RO, so that
if either are not set, there is a clearer upfront Django error about
Databases not being configured, rather than timeouts trying to connect
to localhost.

This makes it more obvious when setting up a new instance that the
variables are not present in the environment (and would have avoided
some confusion on Heroku today, when DATABASE_URL was set, but
DATABASE_URL_RO was not) - in exchange for now needing two extra lines
in the puppet config for local testing.
2015-07-15 16:20:39 +01:00
Ed Morley 58813b0c51 Bug 1169916 - Stop using Cython to build the log parser
Since it only speeds up parsing by a few percent of total runtime, and
is therefore not worth the added complexity for deployment and local
hack-test-debug cycles when working on the log parser.

The .gitignore and update.py entries will be removed in a later commit,
once the stage/prod src directories have been cleaned up.
2015-06-30 14:51:57 +01:00
Cameron Dawson 0bba64b620 Cleanup syntax in .bash_aliases 2015-06-30 12:37:31 +01:00
Ed Morley bf4c7c05ff Bug 1151803 - Serve the UI using gunicorn/WhiteNoise instead of Apache
In order that we can serve the UI on Heroku, we wrap the Django wsgi app
with WhiteNoise, so both the UI and API requests are served by gunicorn.

In the Vagrant environment, Apache has been removed and Varnish instead
now proxies all requests to gunicorn/Django runserver directly, without
Apache as a go-between.

The UI on production will not be affected by this commit, since the
Apache config there will still intercept requests for the UI assets
rather than proxying them to gunicorn.

It's worth noting too, that we're not able to make use of WhiteNoise's
automatic Django GZip/caching support since that assumes we are using
Django templates and referring to resources using {% static "foo.css" %}

However, we can sub-class WhiteNoise (or more specifically the
DjangoWhiteNoise class) and override the is_immutable_file() method to
add caching support at a later date:
http://whitenoise.evans.io/en/latest/base.html#caching-headers

Documentation for WhiteNoise can be found at:
http://whitenoise.evans.io/
2015-06-19 15:56:23 +01:00
Ed Morley 4c827ab288 Bug 1151803 - Vagrant: Stop using Varnish to gzip json/text
Since we should be doing this using Django's GZip middleware, not in
Varnish, which is only used in development. At least with this removed,
we won't check a local instance and believe we have everything set up
correctly if its not.
2015-06-19 13:20:33 +01:00
Ed Morley fca98929db Bug 1151803 - Vagrant: Remove socketio remnant from Varnish config
Leftover from bug 1076710.
2015-06-19 13:20:32 +01:00
Cameron Dawson 9acd164b8a Merge branch 'vagrant-thresetall-alias-improvements' 2015-06-17 15:30:58 -07:00
William Lachance 5fea0d4b13 Bug 1167349 - Turn swagger back on in production and update to latest 2015-06-17 14:13:14 -04:00
Cameron Dawson 5afcf40f13 Bug 1175334 - improve thresetall alias in vagrant
delete ``celerybeat-schedule``, restart rabbitmq, and echo what it’s
doing as it goes.
2015-06-16 16:23:03 -07:00
Cameron Dawson 111c09ad05 Merge branch 'fix-thresetall' 2015-06-10 12:42:31 -07:00
Cameron Dawson f238a9cf31 Bug 1173192 - Fix and enhance the .bash_aliases file 2015-06-10 12:42:13 -07:00
Ed Morley 80537079c8 Bug 1172036 - Vagrant: Run export_project_credentials during provision
This means there is one less manual step that has to be performed during
initial setup.
2015-06-10 00:02:55 +01:00
Cameron Dawson 37d8a6b4c6 Bug 1171757 - create a vagrant .bash_aliases with helpful functions 2015-06-09 10:52:20 -07:00
Ed Morley e20a80ddcb Bug 1170805 - Vagrant: Reduce repetition in apache config 2015-06-03 11:56:52 +01:00
Ed Morley 6583580291 Bug 1170805 - Vagrant: Remove redirect for old style /ui/ URLs 2015-06-03 11:56:51 +01:00
Ed Morley 81c5c67a2a Bug 1170167 - Vagrant: cd into the treeherder directory on login
Also switches the activate-venv-on-login .bashrc entry to use an
absolute path, in case it gets added to .bashrc after the 'cd' line.
2015-06-02 13:44:55 +01:00
Ed Morley 6d813129a4 Bug 1170167 - Vagrant: Use a $HOME_DIR variable to reduce repetition 2015-06-02 13:44:54 +01:00
Ed Morley 9472ffabf7 Bug 1144804 - Vagrant: Remove workaround for older versions of puppet
This removes the puppet workaround added by bug 1144805, since the
Ubuntu 14.04 vagrant image comes with puppet 3.4.3, and so includes the
fix for:
https://projects.puppetlabs.com/issues/10907
2015-06-01 11:37:04 +01:00
Ed Morley feb283bbdd Bug 1144804 - Vagrant: Stop installing make
Since it's available by default in Ubuntu 14.04.
2015-06-01 11:37:03 +01:00
Ed Morley 820e65be9d Bug 1144804 - Vagrant: Stop installing curl
Since it's available by default in Ubuntu 14.04.
2015-06-01 11:37:02 +01:00
Ed Morley a13b143c7b Bug 1144804 - Vagrant: Stop installing python-software-properties
Since we can use add-apt-repository in Ubuntu 14.04 without installing
additional packages.
2015-06-01 11:37:01 +01:00
Ed Morley b137b9148b Bug 1144804 - Vagrant: Update base image from Ubuntu 12.04 to 14.04
This uses the newer image from:
https://vagrantcloud.com/ubuntu/boxes/trusty32

This also updates us from apache 2.2 to apache 2.4, which means the
apache config must be changed to be compatible with apache 2.4:
http://httpd.apache.org/docs/2.4/upgrading.html
(The syntax for "Allow from all" has changed, plus the default config
now specifies a "Require all denied" which we have to override for the
UI directory)
2015-06-01 11:37:01 +01:00
Ed Morley 6f76ff1780 Bug 1144804 - Vagrant: Fix race conditions with apache setup
A few puppet steps were either depending on the wrong package (ie
apache2-dev instead of apache2) or else did not have a 'requires'
property set at all. This was causing errors during provision due to
races - particularly after updating to Ubuntu 14.04.
2015-06-01 11:37:00 +01:00