Horizon fails with Django-1.7

Bug #1382023 reported by Matthias Runge
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Critical
Julie Pichon
Icehouse
Fix Released
High
Julie Pichon
Juno
Fix Released
Medium
Julie Pichon

Bug Description

as reported here: http://lists.alioth.debian.org/pipermail/openstack-devel/2014-October/007488.html

or with this backtrace, horizon Juno and Icehouse in Debian fail with this backtrace:

http://paste.fedoraproject.org/142396/13459234/

[Thu Oct 16 11:33:45.901644 2014] [:error] [pid 1581] [remote ::1:27029] mod_wsgi (pid=1581): Exception occurred processing WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi'.
[Thu Oct 16 11:33:45.901690 2014] [:error] [pid 1581] [remote ::1:27029] Traceback (most recent call last):
[Thu Oct 16 11:33:45.901707 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 168, in __call__
[Thu Oct 16 11:33:45.901793 2014] [:error] [pid 1581] [remote ::1:27029] self.load_middleware()
[Thu Oct 16 11:33:45.901807 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 46, in load_middleware
[Thu Oct 16 11:33:45.901879 2014] [:error] [pid 1581] [remote ::1:27029] mw_instance = mw_class()
[Thu Oct 16 11:33:45.901889 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/middleware/locale.py", line 23, in __init__
[Thu Oct 16 11:33:45.901929 2014] [:error] [pid 1581] [remote ::1:27029] for url_pattern in get_resolver(None).url_patterns:
[Thu Oct 16 11:33:45.901939 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 367, in url_patterns
[Thu Oct 16 11:33:45.902065 2014] [:error] [pid 1581] [remote ::1:27029] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
[Thu Oct 16 11:33:45.902076 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 361, in urlconf_module
[Thu Oct 16 11:33:45.902091 2014] [:error] [pid 1581] [remote ::1:27029] self._urlconf_module = import_module(self.urlconf_name)
[Thu Oct 16 11:33:45.902099 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Thu Oct 16 11:33:45.902134 2014] [:error] [pid 1581] [remote ::1:27029] __import__(name)
[Thu Oct 16 11:33:45.902146 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/urls.py", line 36, in <module>
[Thu Oct 16 11:33:45.902182 2014] [:error] [pid 1581] [remote ::1:27029] url(r'', include(horizon.urls))
[Thu Oct 16 11:33:45.902191 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 29, in include
[Thu Oct 16 11:33:45.902231 2014] [:error] [pid 1581] [remote ::1:27029] patterns = getattr(urlconf_module, 'urlpatterns', urlconf_module)
[Thu Oct 16 11:33:45.902242 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 224, in inner
[Thu Oct 16 11:33:45.902336 2014] [:error] [pid 1581] [remote ::1:27029] self._setup()
[Thu Oct 16 11:33:45.902346 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 357, in _setup
[Thu Oct 16 11:33:45.902359 2014] [:error] [pid 1581] [remote ::1:27029] self._wrapped = self._setupfunc()
[Thu Oct 16 11:33:45.902367 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/horizon/base.py", line 778, in url_patterns
[Thu Oct 16 11:33:45.902525 2014] [:error] [pid 1581] [remote ::1:27029] return self._urls()[0]
[Thu Oct 16 11:33:45.902537 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/horizon/base.py", line 812, in _urls
[Thu Oct 16 11:33:45.902552 2014] [:error] [pid 1581] [remote ::1:27029] url(r'^%s/' % dash.slug, include(dash._decorated_urls)))
[Thu Oct 16 11:33:45.902561 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/horizon/base.py", line 487, in _decorated_urls
[Thu Oct 16 11:33:45.902573 2014] [:error] [pid 1581] [remote ::1:27029] url(r'^%s/' % url_slug, include(panel._decorated_urls)))
[Thu Oct 16 11:33:45.902581 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/horizon/base.py", line 257, in _decorated_urls
[Thu Oct 16 11:33:45.902604 2014] [:error] [pid 1581] [remote ::1:27029] urlpatterns = self._get_default_urlpatterns()
[Thu Oct 16 11:33:45.902611 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/horizon/base.py", line 87, in _get_default_urlpatterns
[Thu Oct 16 11:33:45.902622 2014] [:error] [pid 1581] [remote ::1:27029] urls_mod = import_module('.urls', package_string)
[Thu Oct 16 11:33:45.902629 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 46, in import_module
[Thu Oct 16 11:33:45.902669 2014] [:error] [pid 1581] [remote ::1:27029] __import__(name)
[Thu Oct 16 11:33:45.902680 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/urls.py", line 18, in <module>
[Thu Oct 16 11:33:45.902721 2014] [:error] [pid 1581] [remote ::1:27029] import openstack_dashboard.dashboards.project. \\
[Thu Oct 16 11:33:45.902731 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/views.py", line 25, in <module>
[Thu Oct 16 11:33:45.902775 2014] [:error] [pid 1581] [remote ::1:27029] import openstack_dashboard.dashboards.project.data_processing. \\
[Thu Oct 16 11:33:45.902785 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/dashboards/project/data_processing/nodegroup_templates/tables.py", line 77, in <module>
[Thu Oct 16 11:33:45.902829 2014] [:error] [pid 1581] [remote ::1:27029] class NodegroupTemplatesTable(tables.DataTable):
[Thu Oct 16 11:33:45.902839 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/horizon/tables/base.py", line 1031, in __new__
[Thu Oct 16 11:33:45.903134 2014] [:error] [pid 1581] [remote ::1:27029] attrs["_meta"] = opts = DataTableOptions(attrs.get("Meta", None))
[Thu Oct 16 11:33:45.903148 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/horizon/tables/base.py", line 947, in __init__
[Thu Oct 16 11:33:45.903162 2014] [:error] [pid 1581] [remote ::1:27029] verbose_name = (getattr(options, 'verbose_name', None)
[Thu Oct 16 11:33:45.903170 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/utils/functional.py", line 132, in __wrapper__
[Thu Oct 16 11:33:45.903182 2014] [:error] [pid 1581] [remote ::1:27029] res = func(*self.__args, **self.__kw)
[Thu Oct 16 11:33:45.903190 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 83, in ugettext
[Thu Oct 16 11:33:45.903247 2014] [:error] [pid 1581] [remote ::1:27029] return _trans.ugettext(message)
[Thu Oct 16 11:33:45.903258 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 325, in ugettext
[Thu Oct 16 11:33:45.903390 2014] [:error] [pid 1581] [remote ::1:27029] return do_translate(message, 'ugettext')
[Thu Oct 16 11:33:45.903401 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 306, in do_translate
[Thu Oct 16 11:33:45.903414 2014] [:error] [pid 1581] [remote ::1:27029] _default = translation(settings.LANGUAGE_CODE)
[Thu Oct 16 11:33:45.903422 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 209, in translation
[Thu Oct 16 11:33:45.903433 2014] [:error] [pid 1581] [remote ::1:27029] default_translation = _fetch(settings.LANGUAGE_CODE)
[Thu Oct 16 11:33:45.903441 2014] [:error] [pid 1581] [remote ::1:27029] File "/usr/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 189, in _fetch
[Thu Oct 16 11:33:45.903460 2014] [:error] [pid 1581] [remote ::1:27029] "The translation infrastructure cannot be initialized before the "
[Thu Oct 16 11:33:45.903482 2014] [:error] [pid 1581] [remote ::1:27029] AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.

Matthias Runge (mrunge)
Changed in horizon:
importance: Undecided → Critical
milestone: none → 2014.2
tags: added: icehouse-backport-potential
Revision history for this message
Thomas Goirand (thomas-goirand) wrote :

Hi,

Similar issue seems to affect Debian SId/Jessie (with Horizon from Icehouse), and must also affect Horizon in Debian Experimental (eg: Juno):

http://lists.alioth.debian.org/pipermail/openstack-devel/2014-October/007488.html

I would very much it to be fixed soon, especially because Jessie will be frozen on the 5th of November.

Revision history for this message
Julie Pichon (jpichon) wrote :

Replacing our import + wsgi app creation function in django.wsgi [1] appears to resolve the problem:

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Looking at the Django source all the way back to 1.4 [2], it looks like we should be able to use this safely without breaking backwards-compatibility. Woohoo!

[1] https://github.com/openstack/horizon/blob/master/openstack_dashboard/wsgi/django.wsgi
[2] https://github.com/django/django/blob/1.4.15/django/core/wsgi.py

Changed in horizon:
assignee: nobody → Julie Pichon (jpichon)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/128911

Changed in horizon:
status: New → In Progress
Revision history for this message
Akihiro Motoki (amotoki) wrote :

Julie's solution is correct. Django 1.7 release note mentions this. We should switch earlier...

https://docs.djangoproject.com/en/1.7/releases/1.7/#wsgi-scripts

Revision history for this message
Julie Pichon (jpichon) wrote :

Thanks for linking to the release notes Akihiro, that is helpful and I had missed it. I'm going to mark this as a juno backport potential since it's been causing pain to some distributors.

tags: added: juno-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/128911
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=686af384c201148c3aebcfbf18b2527587d70ea4
Submitter: Jenkins
Branch: master

commit 686af384c201148c3aebcfbf18b2527587d70ea4
Author: Julie Pichon <email address hidden>
Date: Thu Oct 16 13:46:10 2014 +0100

    Update WSGI app creation to be compatible with Django 1.7

    This resolves the following error when trying to run Horizon:

    AppRegistryNotReady: The translation infrastructure cannot be
    initialized before the apps registry is ready. Check that you don't
    make non-lazy gettext calls at import time.

    and is backwards-compatible with our currently supported versions (back
    to 1.4).

    Change-Id: I1e59f2bf6633a34cfe9230aa028f345e5fa70f94
    Closes-Bug: #1382023

Changed in horizon:
status: In Progress → Fix Committed
Matthias Runge (mrunge)
Changed in horizon:
milestone: 2014.2 → kilo-1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (stable/juno)

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/129219

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (stable/icehouse)

Fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/129222

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (stable/icehouse)

Reviewed: https://review.openstack.org/129222
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=e5a9037d2ff5f2fbd5bde8e073e90b8d290994d3
Submitter: Jenkins
Branch: stable/icehouse

commit e5a9037d2ff5f2fbd5bde8e073e90b8d290994d3
Author: Julie Pichon <email address hidden>
Date: Thu Oct 16 13:46:10 2014 +0100

    Update WSGI app creation to be compatible with Django 1.7

    This resolves the following error when trying to run Horizon:

    AppRegistryNotReady: The translation infrastructure cannot be
    initialized before the apps registry is ready. Check that you don't
    make non-lazy gettext calls at import time.

    and is backwards-compatible with our currently supported versions (back
    to 1.4).

    Change-Id: I1e59f2bf6633a34cfe9230aa028f345e5fa70f94
    Closes-Bug: #1382023
    (cherry picked from commit 686af384c201148c3aebcfbf18b2527587d70ea4)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (stable/juno)

Reviewed: https://review.openstack.org/129219
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=9e777f2530f3cecda97f4a0c2b261afe89dc295d
Submitter: Jenkins
Branch: stable/juno

commit 9e777f2530f3cecda97f4a0c2b261afe89dc295d
Author: Julie Pichon <email address hidden>
Date: Thu Oct 16 13:46:10 2014 +0100

    Update WSGI app creation to be compatible with Django 1.7

    This resolves the following error when trying to run Horizon:

    AppRegistryNotReady: The translation infrastructure cannot be
    initialized before the apps registry is ready. Check that you don't
    make non-lazy gettext calls at import time.

    and is backwards-compatible with our currently supported versions (back
    to 1.4).

    Change-Id: I1e59f2bf6633a34cfe9230aa028f345e5fa70f94
    Closes-Bug: #1382023
    (cherry picked from commit 686af384c201148c3aebcfbf18b2527587d70ea4)

Akihiro Motoki (amotoki)
tags: added: in-stable-icehouse in-stable-juno
removed: icehouse-backport-potential juno-backport-potential
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: kilo-1 → 2015.1.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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