With Havana 2 installed, Launching horizon UI results in the error " NameError: name 'Dashboard' is not defined"

Bug #1210253 reported by Vivekanandan B
66
This bug affects 13 people
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
Radomir Dopieralski
Ubuntu Cloud Archive
Fix Released
Undecided
Unassigned
horizon (Debian)
New
Undecided
Unassigned
horizon (Ubuntu)
Fix Released
Undecided
Unassigned
Saucy
Fix Released
Undecided
Unassigned

Bug Description

Hi All,

I installed Havana2, after installation Launching horizon UI results in the error " NameError: name 'Dashboard' is not defined".
Havana 2 was installed from "deb http://ppa.launchpad.net/ubuntu-cloud-archive/havana-staging/ubuntu precise main"

Below is the log snippet from apache2:

[Thu Aug 08 09:44:41 2013] [error] Warning: Could not import Horizon dependencies. This is normal during installation.
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] mod_wsgi (pid=16851): Exception occurred processing WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi'.
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] Traceback (most recent call last):
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 236, in __call__
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] self.load_middleware()
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 53, in __getattr__
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] self._setup(name)
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 48, in _setup
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] self._wrapped = Settings(settings_module)
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] mod = importlib.import_module(self.SETTINGS_MODULE)
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] __import__(name)
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/settings.py", line 182, in <module>
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] from local.local_settings import *
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/local/local_settings.py", line 91, in <module>
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] from horizon.utils import secret_key
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] File "/usr/lib/python2.7/dist-packages/horizon/__init__.py", line 55, in <module>
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] assert Dashboard
[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] NameError: name 'Dashboard' is not defined [Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] File does not exist: /var/www/favicon.ico

Related branches

Revision history for this message
Ashok kumaran B (ashokkumaran-b) wrote :

Dashboard debs were installed like below

apt-get install -y openstack-dashboard memcached python-memcache

Revision history for this message
Muhammad Rehan Shaukat (rehan-shaukat) wrote :

Having same problem after upgrading to Havana from cloud archive "deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/havana main"

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

I haven't seen this is on master or in other environments, it appears to be affecting people who installed using the ubuntu cloud archive. Adding the project to the bug to see if they can provide some insight.

Changed in horizon:
status: New → Incomplete
Revision history for this message
Ante Karamatić (ivoks) wrote :

Well, I would argue that for yet unknown reason Cloud Archive exposes one bug. If you look at Horizon's __init__.py, you'll notice:

try:
    from horizon.base import Dashboard
    from horizon.base import Horizon
    from horizon.base import Panel
    from horizon.base import PanelGroup
except ImportError:
   ...do some other things...

It's perfectly possible (as it is with Cloud Archive for some reason) to not import Dashboard, Horizon, Panel and PanelGroup. And this is expected and there's even a warning raised. But, at the end of the file:

assert Dashboard
assert Panel
assert PanelGroup

Taking into account that try might fail, it's wrong to assume that Dashboard, Panel and PanelGroup are defined. Which is what python is complaining about:

[Thu Aug 08 09:44:41 2013] [error] [client 10.1.6.45] NameError: name 'Dashboard' is not defined

So, I would say there are two bugs hidden here. One is wrong assumption in Horizon that Dashboard, Panel and PanelGroup are defined and the other one is about Horizon in Cloud Archive not importing these modules.

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

Right, these assert were added during Havana-2 indeed, and contradict the comments earlier in the file.

Could people affected by this bug try removing the assert and see if Horizon then works, or if it hides another issue?

Changed in horizon:
status: Incomplete → Triaged
Revision history for this message
Ante Karamatić (ivoks) wrote :

Funny part is that if I just put imports without 'try', they do work. Later on Horizon fails with a different error:

WARNING:root:No local_settings file found.
ImproperlyConfigured: The SECRET_KEY setting must not be empty.

I can reproduce it with Django 5.1. Julie what Django version do you have?

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

I'm running with an older Django at the moment, I'll try with an updated version. The SECRET_KEY error is different though, you should configure a local_settings.py file (based off openstack_dashboard/local/local_settings.py) that has a secret key set. Packages usually install this file in /etc/openstack_dashboard/local_settings.py AFAIK.

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

This may be unrelated -- I can't tell because it fails without a stack trace that I can find -- but running with Django 1.5.2 and DEBUG=False and trying to access the login page fails with "Something went wrong", while this works fine with Django 1.4.5 (devstack). I'll open a new bug if I can get a stack trace and it's different, someone feel free to beat me to it if you can reproduce with useful logs.

Revision history for this message
Ante Karamatić (ivoks) wrote :

Right, I think you are getting the same problem. Django pre 1.5.x didn't have this problem, so this might be an incompatibility problem between Horizon and Django 1.5.x.

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

Sorry, comment #8 is my bad and can be ignored, it's not related to this bug at all. In the local_settings.py, right below DEBUG there is the ALLOWED_HOSTS variable with a comment that indicates it's required with Django 1.5.

So I still can't reproduce this bug after all.

Revision history for this message
Ante Karamatić (ivoks) wrote :

We've found some issues in packaging of horizon in Cloud Archive. Once we resolve those, we'll see if problem persist.

Changed in cloud-archive:
status: New → Confirmed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package horizon - 1:2013.2~b2-0ubuntu3

---------------
horizon (1:2013.2~b2-0ubuntu3) saucy; urgency=low

  * debian/rules: Don't remove egg information while cleaning.
    (LP: #1210253)
 -- Chuck Short <email address hidden> Wed, 21 Aug 2013 10:08:35 -0400

Changed in horizon (Ubuntu Saucy):
status: New → Fix Released
Revision history for this message
Gabriel Hurley (gabriel-hurley) wrote :

This was not a bug in Horizon trunk.

Changed in horizon:
status: Triaged → Invalid
Pei Pan (peipan.cst.zju)
Changed in horizon:
status: Invalid → Confirmed
status: Confirmed → Invalid
Revision history for this message
Pei Pan (peipan.cst.zju) wrote :

I have just found the same problem.
The log is as like:
413 [Thu Sep 26 13:47:55 2013] [error] Warning: Could not import Horizon dependencies. This is normal during installation.
414 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] mod_wsgi (pid=11717): Exception occurred processing WSGI script '/usr/share/op enstack-dashboard/openstack_dashboard/wsgi/django.wsgi'.
415 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] Traceback (most recent call last):
416 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 2 36, in __call__
417 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] self.load_middleware()
418 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 4 5, in load_middleware
419 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] for middleware_path in settings.MIDDLEWARE_CLASSES:
420 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 53, in __getattr__
421 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] self._setup(name)
422 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 48, in _setup
423 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] self._wrapped = Settings(settings_module)
424 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, i n __init__
425 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] mod = importlib.import_module(self.SETTINGS_MODULE)
426 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
427 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] __import__(name)
428 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstac k_dashboard/settings.py", line 182, in <module>
429 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] from local.local_settings import *
430 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstac k_dashboard/local/local_settings.py", line 91, in <module>
431 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] from horizon.utils import secret_key
432 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] File "/usr/lib/python2.7/dist-packages/horizon/__init__.py", line 55, in <mo dule>
433 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] assert Dashboard
434 [Thu Sep 26 13:47:55 2013] [error] [client 192.168.1.228] NameError: name 'Dashboard' is not defined

I don't know why appear this problem!

Revision history for this message
Julian Sternberg (jules-i) wrote :

Same Problem here. How have you fixed this?!?!?!

My log looks like this:
[Thu Sep 26 17:47:41 2013] [error] Warning: Could not import Horizon dependencies. This is normal during installation.
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] mod_wsgi (pid=3432): Exception occurred processing WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi'.
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] Traceback (most recent call last):
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] self.load_middleware()
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 39, in load_middleware
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] File "/usr/lib/python2.7/dist-packages/django/utils/functional.py", line 184, in inner
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] self._setup()
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] self._wrapped = Settings(settings_module)
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 93, in __init__
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] mod = importlib.import_module(self.SETTINGS_MODULE)
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] __import__(name)
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/settings.py", line 182, in <module>
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] from local.local_settings import *
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi/../../openstack_dashboard/local/local_settings.py", line 91, in <module>
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] from horizon.utils import secret_key
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] File "/usr/lib/python2.7/dist-packages/horizon/__init__.py", line 55, in <module>
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] assert Dashboard
[Thu Sep 26 17:47:41 2013] [error] [client 77.47.27.xxx] NameError: name 'Dashboard' is not defined

Revision history for this message
Brian Cline (briancline) wrote :

I'm also seeing this behavior. No change when installing from the current Havana packages in Ubuntu cloud archive under 12.04 (Precise), but looks like the fix (#12) was only released to saucy.

Any ideas when 1:2013.2~b2-0ubuntu3~cloud0 will hit precise?

Revision history for this message
Phil Frost (bitglue) wrote :

The cloud archive does not yet have the fix. It's not terribly hard to patch the packages locally, though. Summary:

apt-get install build-essential
apt-get source horizon
apt-get build-dep horizon
cd horizon-*
# apply the changes to debian/rules and debian/changelog at
# http://launchpadlibrarian.net/148082203/horizon_1%3A2013.2~b2-0ubuntu2_1%3A2013.2~b2-0ubuntu3.diff.gz
# (although probably you will want a different version number, so
# the next ubuntu cloud archive version superceeds yours)
dpkg-buildpackage -us -uc
cd ..

install the resulting .debs with "dpkg -i", or put them in a ppa, or some other repo, etc.

I've confirmed that these changes fix at least the problem described here. I'm then having a different problem: when I log in, I get redirected back to the login page, with no error in the browser or apache's error.log that I can find. However, that is probably more likely something I did wrong upgrading from grizzly to havanah, or a separate issue.

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

@Phil Frost: If you are now using Django 1.5, make sure ALLOWED_HOSTS is set correctly in your local_settings.py.

https://github.com/openstack/horizon/blob/master/openstack_dashboard/local/local_settings.py.example#L10
https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts

Revision history for this message
Tom Fifield (fifieldt) wrote :

This bug is still present in the Ubuntu cloud archive.

Revision history for this message
Adam Gandelman (gandelman-a) wrote :

Just tested with a fresh system and fresh package installation from the Cloud Archive Havana proposed pocket. Installed horizon 1:2013.2~rc1-0ubuntu2~cloud0 (havana release candidate) and everything is working fine. Steps to do minimal test:

apt-get install openstack-dashboard
edit /etc/openstack-dashboard/local_settings.py, update OPENSTACK_HOST to point to your keystone hostname.
restart apache2, surf to http://$host/horizon, login.

Be sure you're using the most recent package version. Note there are 3 pockets in the Cloud Archive and I suspect you are using the -updates pocket which, during the dev. cycle, does not get as frequent updates as the -staging and -proposed pockets.

Revision history for this message
James Page (james-page) wrote :

All packages now synced to updates pocket; marking Fix Released.

Changed in cloud-archive:
status: Confirmed → Fix Released
Changed in openstack-cisco:
assignee: nobody → Mark T. Voelker (mvoelker)
importance: Undecided → High
milestone: none → h.0
status: New → In Progress
Revision history for this message
Radomir Dopieralski (deshipu) wrote :

I can still see the contradictory code in horizon/__init__.py. Should that be fixed too?
I mean, if we decide that we do require Dashboard, Panel and PanelGroup, then maybe we should remove the try-except and warnings? If we decide that they are optional after all, then we should remove the asserts?

Also, why asserts, when using __all__ also makes flake8 shut up and actually is the idiomatic way of telling Python what those modules should me exposed.

Changed in horizon:
status: Invalid → Incomplete
Revision history for this message
Julie Pichon (jpichon) wrote :

@Radomir: Sounds good and a nicer way to do it! Mind filing a new bug to track it? That pattern is repeated in a few places.

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/56547

Changed in horizon:
assignee: nobody → Radomir Dopieralski (thesheep)
status: Incomplete → In Progress
Revision history for this message
Victor Morales (electrocucaracha) wrote :

I'm not sure if this is too late but I was getting the same error everytime that I started an instance of the horizon layer. I discovered that I was using the version 1.6 of Django and it has some classes deprecated(https://docs.djangoproject.com/en/dev/internals/deprecation/), specially django.conf.urls.defaults. My workaround was to downgrade to 1.5 version and finally works.

David Lyle (david-lyle)
Changed in horizon:
importance: Undecided → High
importance: High → Low
milestone: none → icehouse-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/56547
Committed: http://github.com/openstack/horizon/commit/b6eb9a2480a82cf93f7a62e9c7373feddc8296fe
Submitter: Jenkins
Branch: master

commit b6eb9a2480a82cf93f7a62e9c7373feddc8296fe
Author: Radomir Dopieralski <email address hidden>
Date: Fri Nov 15 10:04:31 2013 +0100

    Remove asserts for optional imports

    Horizon's __init__.py has some code that explicitly allows it to
    be imported by setup.py before Django is set up, by making import
    failures just throw a warning instead of an exception. But that code
    is defeated by a bunch of asserts that were added later, that just
    make the error even more confusing.

    I'm removing the asserts and replacing them with __all__.

    Closes-bug: #1210253
    Change-Id: I0fde7810a033fd7216da9a5460f5e4e323b4d6e9

Changed in horizon:
status: In Progress → Fix Committed
Changed in openstack-cisco:
milestone: h.0 → none
no longer affects: openstack-cisco
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (stable/havana)

Fix proposed to branch: stable/havana
Review: https://review.openstack.org/67401

Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: icehouse-2 → 2014.1
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.