Merge lp:~james-w/canonical-identity-provider/oops2 into lp:canonical-identity-provider/release

Proposed by James Westby
Status: Merged
Approved by: James Westby
Approved revision: no longer in the source branch.
Merged at revision: 734
Proposed branch: lp:~james-w/canonical-identity-provider/oops2
Merge into: lp:canonical-identity-provider/release
Diff against target: 159 lines (+74/-14)
7 files modified
.bzrignore (+1/-0)
django_project/config_dev/config/devel.cfg (+16/-0)
django_project/config_dev/django.wsgi (+16/-13)
identityprovider/schema.py (+4/-0)
identityprovider/wsgi_handler.py (+32/-0)
requirements/install.txt (+4/-0)
webui/views/errors.py (+1/-1)
To merge this branch: bzr merge lp:~james-w/canonical-identity-provider/oops2
Reviewer Review Type Date Requested Status
Ricardo Kirkner (community) Approve
Review via email: mp+153935@code.launchpad.net

Commit message

Prepare for moving to v2 of the oops stack.

Description of the change

Hi,

This is the prep that is needed for moving to v2 of the oops stack.

It's not perfect yet, as a limitation in the oops stack means we currently
have to choose between showing the user the id of their oops, and having reliable
delivery if amqp is down. I'm working on fixing that limitation, and we can
adopt that when it is ready so that we don't have to choose.

Some comments:

  * There are extra requirements that this brings. They should all be
    packaged in CAT already, so I think it should be a case of adding them
    to the dependencies packaage and getting them installed?

  * It requires some config being set to get the oopses delivered, but the
    code won't have a problem if it isn't set. How is the config delivered
    to production for SSO?

  * I didn't make use of settings.BRAND for the new oopses. I'm not sure what
    it is for. However we can adjust the reporter or the template to include
    extra information if we like. If the info is dynamic and important to have
    then I can add the code for it.

Thanks,

James

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

Oh, I renamed the wsgi symlink so that I could use it with runserver, as it needs to
import it. I can undo that if it's not correct.

Thanks,

James

Revision history for this message
James Westby (james-w) wrote :

nessita points out that sourcedeps might be preferred to pip now. Also sso is on lucid, and
the packages we have will be for precise.

There's also a question of whether requirements.txt should list all the new deps (e.g. the
amqp library that oops_amqp will use), or just the top-level ones.

Revision history for this message
Ricardo Kirkner (ricardokirkner) wrote :

Approving, but noting some extra things we need to add in later

- add requirements as sourcedeps
- add tests for wsgi_handler.py
- add a way for testing wsgi.py

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (5.5 KiB)

The attempt to merge lp:~james-w/canonical-identity-provider/oops2 into lp:canonical-identity-provider failed. Below is the output from the failed tests.

Updating download cache at dir /mnt/tarmac/cache/isd-download-cache
Using saved parent location: bzr+ssh://bazaar.launchpad.net/~canonical-isd-hackers/+junk/download-cache/
No revisions or tags to pull.
[localhost] local: which virtualenv
[localhost] local: /usr/bin/python /usr/bin/virtualenv --version
[localhost] local: /usr/bin/python /usr/bin/virtualenv --distribute --clear .env
Not deleting .env/bin
New python executable in .env/bin/python
Installing distribute.............................................................................................................................................................................................done.
Installing pip...............done.
[localhost] local: dpkg -l libpq-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l libxml2-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l libxslt1-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l memcached 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l postgresql-plpython-9.1 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-m2crypto 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l swig 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l config-manager 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-egenix-mx-base-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: rm -rf M2Crypto*
[localhost] local: ln -s /usr/lib/python2.7/dist-packages/M2Crypto* .
[localhost] local: /usr/lib/config-manager/cm.py update /tmp/tmpHHZDAd
[localhost] local: . /mnt/tarmac/cache/canonical-identity-provider/trunk/.env/bin/activate && make install PACKAGES="-r /mnt/tarmac/cache/canonical-identity-provider/trunk/requirements.txt"
pip install --find-links=file:///mnt/tarmac/cache/isd-download-cache --no-index pip==dev
Ignoring indexes: http://pypi.python.org/simple/
Downloading/unpacking pip==dev
  Running setup.py egg_info for package pip

    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: pip
  Found existing installation: pip 1.1
    Uninstalling pip:
      Successfully uninstalled pip
  Running setup.py install for pip

    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
    Installing pip script to /mnt/tarmac/cache/canonical-identity-provider/trunk/.env/bin
    Installing pip-2.7 script to /mnt/tarmac/cache/canonical-identity-provider/trunk/.env/bin
Successfully installed pip
Cleaning up...
pip install --find-links=. --no-index -r /mnt/tarmac/cache/canonical-identity-provider/trunk/requirements.txt
Ignoring indexes: ht...

Read more...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (8.9 KiB)

The attempt to merge lp:~james-w/canonical-identity-provider/oops2 into lp:canonical-identity-provider failed. Below is the output from the failed tests.

Updating download cache at dir /mnt/tarmac/cache/isd-download-cache
Using saved parent location: bzr+ssh://bazaar.launchpad.net/~canonical-isd-hackers/+junk/download-cache/
No revisions or tags to pull.
[localhost] local: which virtualenv
[localhost] local: /usr/bin/python /usr/bin/virtualenv --version
[localhost] local: /usr/bin/python /usr/bin/virtualenv --distribute --clear .env
Not deleting .env/bin
New python executable in .env/bin/python
Installing distribute.............................................................................................................................................................................................done.
Installing pip...............done.
[localhost] local: dpkg -l libpq-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l libxml2-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l libxslt1-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l memcached 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l postgresql-plpython-9.1 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-m2crypto 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l swig 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l config-manager 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-egenix-mx-base-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: rm -rf M2Crypto*
[localhost] local: ln -s /usr/lib/python2.7/dist-packages/M2Crypto* .
[localhost] local: /usr/lib/config-manager/cm.py update /tmp/tmpU44EE3
[localhost] local: . /mnt/tarmac/cache/canonical-identity-provider/trunk/.env/bin/activate && make install PACKAGES="-r /mnt/tarmac/cache/canonical-identity-provider/trunk/requirements.txt"
pip install --find-links=file:///mnt/tarmac/cache/isd-download-cache --no-index pip==dev
Ignoring indexes: http://pypi.python.org/simple/
Downloading/unpacking pip==dev
  Running setup.py egg_info for package pip

    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: pip
  Found existing installation: pip 1.1
    Uninstalling pip:
      Successfully uninstalled pip
  Running setup.py install for pip

    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
    Installing pip script to /mnt/tarmac/cache/canonical-identity-provider/trunk/.env/bin
    Installing pip-2.7 script to /mnt/tarmac/cache/canonical-identity-provider/trunk/.env/bin
Successfully installed pip
Cleaning up...
pip install --find-links=. --no-index -r /mnt/tarmac/cache/canonical-identity-provider/trunk/requirements.txt
Ignoring indexes: ht...

Read more...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (79.0 KiB)

The attempt to merge lp:~james-w/canonical-identity-provider/oops2 into lp:canonical-identity-provider failed. Below is the output from the failed tests.

Updating download cache at dir /mnt/tarmac/cache/isd-download-cache
Using saved parent location: bzr+ssh://bazaar.launchpad.net/~canonical-isd-hackers/+junk/download-cache/
Now on revision 16.
[localhost] local: which virtualenv
[localhost] local: /usr/bin/python /usr/bin/virtualenv --version
[localhost] local: /usr/bin/python /usr/bin/virtualenv --distribute --clear .env
Not deleting .env/bin
New python executable in .env/bin/python
Installing distribute.............................................................................................................................................................................................done.
Installing pip...............done.
[localhost] local: dpkg -l libpq-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l libxml2-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l libxslt1-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l memcached 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l postgresql-plpython-9.1 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-m2crypto 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l swig 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l config-manager 2> /dev/null | grep '^ii' | wc -l
[localhost] local: dpkg -l python-egenix-mx-base-dev 2> /dev/null | grep '^ii' | wc -l
[localhost] local: rm -rf M2Crypto*
[localhost] local: ln -s /usr/lib/python2.7/dist-packages/M2Crypto* .
[localhost] local: /usr/lib/config-manager/cm.py update /tmp/tmpilY6JQ
[localhost] local: . /mnt/tarmac/cache/canonical-identity-provider/trunk/.env/bin/activate && make install PACKAGES="-r /mnt/tarmac/cache/canonical-identity-provider/trunk/requirements.txt"
pip install --find-links=file:///mnt/tarmac/cache/isd-download-cache --no-index pip==dev
Ignoring indexes: http://pypi.python.org/simple/
Downloading/unpacking pip==dev
  Running setup.py egg_info for package pip

    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: pip
  Found existing installation: pip 1.1
    Uninstalling pip:
      Successfully uninstalled pip
  Running setup.py install for pip

    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
    Installing pip script to /mnt/tarmac/cache/canonical-identity-provider/trunk/.env/bin
    Installing pip-2.7 script to /mnt/tarmac/cache/canonical-identity-provider/trunk/.env/bin
Successfully installed pip
Cleaning up...
pip install --find-links=. --no-index -r /mnt/tarmac/cache/canonical-identity-provider/trunk/requirements.txt
Ignoring indexes: http://pypi....

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2013-03-05 13:51:14 +0000
+++ .bzrignore 2013-03-19 21:11:19 +0000
@@ -28,4 +28,5 @@
28branches/*28branches/*
29django_project/config_dev/config/local.cfg29django_project/config_dev/config/local.cfg
30scripts/local.cfg-30scripts/local.cfg-
31./oopses/*
3132
3233
=== modified file 'django_project/config_dev/config/devel.cfg'
--- django_project/config_dev/config/devel.cfg 2013-03-12 19:14:34 +0000
+++ django_project/config_dev/config/devel.cfg 2013-03-19 21:11:19 +0000
@@ -196,3 +196,19 @@
196196
197[api]197[api]
198api_host = http://%(hostname)s198api_host = http://%(hostname)s
199
200[oopses]
201oopses = oops_config
202
203[oops_config]
204template = oops_template
205publishers = oops_dev_publisher
206
207[oops_template]
208reporter = SSO-DEV
209
210[oops_dev_publisher]
211type = datedir
212error_dir = oopses
213inherit_id = true
214only_new = false
199215
=== modified file 'django_project/config_dev/django.wsgi'
--- django_project/config_dev/django.wsgi 2013-02-22 12:16:44 +0000
+++ django_project/config_dev/django.wsgi 2013-03-19 21:11:19 +0000
@@ -31,16 +31,19 @@
3131
32os.environ['PGCONNECT_TIMEOUT'] = str(settings.PGCONNECT_TIMEOUT)32os.environ['PGCONNECT_TIMEOUT'] = str(settings.PGCONNECT_TIMEOUT)
3333
34default_id = ''.join(x for x in platform.node() if x.isalpha())34from identityprovider.wsgi_handler import OOPSWSGIHandler
35appserver_id = getattr(settings, 'APPSERVER_ID', default_id)35
36appserver_id += settings.BRAND36app = OOPSWSGIHandler()
3737
38app = WSGIHandler()38# Wrap the application in the Oops wsgi app to catch unhandled exceptions
3939# and create oops for them.
4040#
41def application(environ, start_response):41# First we create the config that defines what to do with the oopses.
42 oops_dir = getattr(settings, 'OOPS_DIR', '/tmp')42import oops_dictconfig
43 serializer = 'canonical.oops.serializer.OOPSRFC822Serializer'43from oops_wsgi import make_app, install_hooks
44 oops = OopsWare(app, oops_dir=oops_dir, key=appserver_id, hide_meta=True,44
45 serializer_factory_name=serializer)45config = oops_dictconfig.config_from_dict(settings.OOPSES)
46 return oops(environ, start_response)46install_hooks(config)
47
48# Then we wrap the django app in the oops one
49application = make_app(app, config, oops_on_status=['500'])
4750
=== renamed symlink 'django_project/django.wsgi' => 'django_project/wsgi.py'
=== modified file 'identityprovider/schema.py'
--- identityprovider/schema.py 2013-03-12 19:14:34 +0000
+++ identityprovider/schema.py 2013-03-19 21:11:19 +0000
@@ -18,6 +18,7 @@
18 merge,18 merge,
19)19)
20from django_configglue.schema import schemas20from django_configglue.schema import schemas
21from oops_dictconfig.configglue_options import OopsOption
2122
22from ubuntu_sso_saml.schema import Saml2IdpSchema23from ubuntu_sso_saml.schema import Saml2IdpSchema
2324
@@ -278,6 +279,9 @@
278 session_cookie_secure = BoolOption(default=True)279 session_cookie_secure = BoolOption(default=True)
279 session_cookie_httponly = BoolOption(default=True)280 session_cookie_httponly = BoolOption(default=True)
280281
282 class oopses(Section):
283 oopses = OopsOption()
284
281285
282# merge all contrib schemas into the base schema286# merge all contrib schemas into the base schema
283# order matters287# order matters
284288
=== added file 'identityprovider/wsgi_handler.py'
--- identityprovider/wsgi_handler.py 1970-01-01 00:00:00 +0000
+++ identityprovider/wsgi_handler.py 2013-03-19 21:11:19 +0000
@@ -0,0 +1,32 @@
1import uuid
2
3from oops_wsgi import django as oops_wsgi_django
4
5
6class OOPSWSGIHandler(oops_wsgi_django.OOPSWSGIHandler):
7 """
8 Custom WSGI Handler that generates oops ids when an error is encountered
9 so the ids can be reported to the user.
10 """
11
12 def handle_uncaught_exception(self, request, resolver, exc_info):
13 # Generate OOPS id early so that we can render the error page
14 # right
15 # away and not depend on passing thread locals around.
16 if 'oops.report' in request.environ:
17 unique_id = uuid.uuid4().hex
18 request.environ['oops.report']['id'] = "OOPS-%s" % unique_id
19 return super(OOPSWSGIHandler, self).handle_uncaught_exception(
20 request, resolver, exc_info)
21
22 def __call__(self, environ, start_response):
23 def start_response_with_exc_info(status, headers, exc_info=None):
24 """Custom start_response callback for wsgi."""
25 # This will pass the exception information back to oops_wsgi. It
26 # should not be necessary once
27 # https://code.djangoproject.com/ticket/16674 has been merged.
28 if exc_info is None:
29 exc_info = environ['oops.context'].get('exc_info', None)
30 return start_response(status, headers, exc_info)
31 return super(OOPSWSGIHandler, self).__call__(
32 environ, start_response_with_exc_info)
033
=== added directory 'oopses'
=== modified file 'requirements/install.txt'
--- requirements/install.txt 2013-03-05 15:52:39 +0000
+++ requirements/install.txt 2013-03-19 21:11:19 +0000
@@ -14,6 +14,10 @@
14M2Crypto==0.21.114M2Crypto==0.21.1
15oath==1.015oath==1.0
16oauth==1.0.116oauth==1.0.1
17oops_amqp==0.0.7
18oops_datedir_repo==0.0.20
19oops_dictconfig==0.0.4
20oops_wsgi==0.0.10
17psycopg2==2.4.121psycopg2==2.4.1
18pystatsd==0.1.622pystatsd==0.1.6
19python-memcached==1.4423python-memcached==1.44
2024
=== modified file 'webui/views/errors.py'
--- webui/views/errors.py 2012-12-04 14:17:22 +0000
+++ webui/views/errors.py 2013-03-19 21:11:19 +0000
@@ -13,7 +13,7 @@
1313
14 def __call__(self, request):14 def __call__(self, request):
15 template = loader.get_template(self.template_name)15 template = loader.get_template(self.template_name)
16 oopsid = request.META.get('OOPSID')16 oopsid = request.environ.get('oops.report', {}).get('id', None)
17 atts = {17 atts = {
18 'request': request,18 'request': request,
19 'oopsid': oopsid,19 'oopsid': oopsid,