MAAS wsgi.py fails to load on trusty

Bug #1254047 reported by Diogo Matsubara
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Raphaël Badin

Bug Description

Integration tests fail[1] after installing the MAAS package <1.4+bzr1701+dfsg-0+1737+213~ppa0~ubuntu14.04.> on Trusty using the trusty-proposed archive.

It looks like the new version of django on Trusty <python-django_1.6-1> needs to set up the DJANGO_SETTINGS_MODULE environment variable before importing "django.core.handlers.wsgi". python-django 1.6 also removes the defaults module (which has been deprecated since 1.4), so the code needs update to handle that. This patch http://pastebin.ubuntu.com/6458730/ fixes it but I'm not sure how to test it.

[Thu Nov 21 19:40:29.882038 2013] [:error] [pid 29154:tid 140168832489344] mod_wsgi (pid=29154): Exception occurred processing WSGI script '/usr/share/maas/wsgi.py'.
[Thu Nov 21 19:40:29.882065 2013] [:error] [pid 29154:tid 140168832489344] Traceback (most recent call last):
[Thu Nov 21 19:40:29.882084 2013] [:error] [pid 29154:tid 140168832489344] File "/usr/share/maas/wsgi.py", line 22, in <module>
[Thu Nov 21 19:40:29.882563 2013] [:error] [pid 29154:tid 140168832489344] import django.core.handlers.wsgi
[Thu Nov 21 19:40:29.882583 2013] [:error] [pid 29154:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 11, in <module>
[Thu Nov 21 19:40:29.882689 2013] [:error] [pid 29154:tid 140168832489344] from django.core.handlers import base
[Thu Nov 21 19:40:29.882689 2013] [:error] [pid 29155:tid 140168832489344] mod_wsgi (pid=29155): Target WSGI script '/usr/share/maas/wsgi.py' cannot be loaded as Python module.
[Thu Nov 21 19:40:29.882705 2013] [:error] [pid 29154:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 12, in <module>
[Thu Nov 21 19:40:29.882710 2013] [:error] [pid 29155:tid 140168832489344] mod_wsgi (pid=29155): Exception occurred processing WSGI script '/usr/share/maas/wsgi.py'.
[Thu Nov 21 19:40:29.882736 2013] [:error] [pid 29155:tid 140168832489344] Traceback (most recent call last):
[Thu Nov 21 19:40:29.882766 2013] [:error] [pid 29155:tid 140168832489344] File "/usr/share/maas/wsgi.py", line 22, in <module>
[Thu Nov 21 19:40:29.882834 2013] [:error] [pid 29155:tid 140168832489344] import django.core.handlers.wsgi
[Thu Nov 21 19:40:29.882843 2013] [:error] [pid 29154:tid 140168832489344] from django.db import connections, transaction
[Thu Nov 21 19:40:29.882850 2013] [:error] [pid 29155:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 11, in <module>
[Thu Nov 21 19:40:29.882860 2013] [:error] [pid 29154:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/db/__init__.py", line 83, in <module>
[Thu Nov 21 19:40:29.882935 2013] [:error] [pid 29154:tid 140168832489344] signals.request_started.connect(reset_queries)
[Thu Nov 21 19:40:29.882950 2013] [:error] [pid 29154:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 88, in connect
[Thu Nov 21 19:40:29.882950 2013] [:error] [pid 29155:tid 140168832489344] from django.core.handlers import base
[Thu Nov 21 19:40:29.882967 2013] [:error] [pid 29155:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 12, in <module>
[Thu Nov 21 19:40:29.883072 2013] [:error] [pid 29154:tid 140168832489344] if settings.DEBUG:
[Thu Nov 21 19:40:29.883087 2013] [:error] [pid 29154:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 54, in __getattr__
[Thu Nov 21 19:40:29.883104 2013] [:error] [pid 29155:tid 140168832489344] from django.db import connections, transaction
[Thu Nov 21 19:40:29.883121 2013] [:error] [pid 29155:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/db/__init__.py", line 83, in <module>
[Thu Nov 21 19:40:29.883182 2013] [:error] [pid 29154:tid 140168832489344] self._setup(name)
[Thu Nov 21 19:40:29.883196 2013] [:error] [pid 29155:tid 140168832489344] signals.request_started.connect(reset_queries)
[Thu Nov 21 19:40:29.883197 2013] [:error] [pid 29154:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 47, in _setup
[Thu Nov 21 19:40:29.883212 2013] [:error] [pid 29155:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 88, in connect
[Thu Nov 21 19:40:29.883227 2013] [:error] [pid 29154:tid 140168832489344] % (desc, ENVIRONMENT_VARIABLE))
[Thu Nov 21 19:40:29.883248 2013] [:error] [pid 29154:tid 140168832489344] ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
[Thu Nov 21 19:40:29.883333 2013] [:error] [pid 29155:tid 140168832489344] if settings.DEBUG:
[Thu Nov 21 19:40:29.883349 2013] [:error] [pid 29155:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 54, in __getattr__
[Thu Nov 21 19:40:29.883445 2013] [:error] [pid 29155:tid 140168832489344] self._setup(name)
[Thu Nov 21 19:40:29.883460 2013] [:error] [pid 29155:tid 140168832489344] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 47, in _setup
[Thu Nov 21 19:40:29.883483 2013] [:error] [pid 29155:tid 140168832489344] % (desc, ENVIRONMENT_VARIABLE))
[Thu Nov 21 19:40:29.883504 2013] [:error] [pid 29155:tid 140168832489344] ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

[1] http://d-jenkins.ubuntu-ci:8080/view/MAAS/job/trusty-adt-maas-manual/ARCH=amd64,label=lenovo-RD230-01/2/consoleText

Tags: django-1.6

Related branches

Raphaël Badin (rvb)
Changed in maas:
importance: Undecided → Critical
status: New → Triaged
tags: added: django-1.6
Revision history for this message
Raphaël Badin (rvb) wrote :

> It looks like the new version of django on Trusty <python-django_1.6-1> needs to set up the DJANGO_SETTINGS_MODULE
> environment variable before importing "django.core.handlers.wsgi". python-django 1.6 also removes the defaults module (which
> has been deprecated since 1.4), so the code needs update to handle that. This patch http://pastebin.ubuntu.com/6458730/ fixes it
> but I'm not sure how to test it.

The fix look sane. fwiw, we kept using django.conf.urls.defaults to be able to have a backported version of MAAS working on precise (with Django 1.3). If we still want to keep that compatibility, we need to continue importing from django.conf.urls.defaults when the Django version is 1.3. But now that using the cloud archive is the preferred way to get a backported version of MAAS working on precise, I don't think we need MAAS to stay Django 1.3-compatible.

Raphaël Badin (rvb)
Changed in maas:
milestone: none → 14.04
Revision history for this message
Julian Edwards (julian-edwards) wrote :

Happy to drop support for 1.3, it's very old now and we're focusing on trusty.

Raphaël Badin (rvb)
Changed in maas:
assignee: nobody → Raphaël Badin (rvb)
status: Triaged → In Progress
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.