messages when the module import fails are very misleading and not descriptive
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
oslo.utils |
Expired
|
Undecided
|
Unassigned |
Bug Description
I had problem to import vmware module due to lack of it's dep. The message in log though was saying that there is no vmware module, which is far from true. The problematic code is at least:
/usr/lib/
def import_
...
try:
return getattr(
except (ValueError, AttributeError):
raise ImportError('Class %s cannot be found (%s)' %
Which would obfuscate the error message when some module import dies on ValueError, and:
def import_
"""Tries to import object from default namespace.
Imports a class and return an instance of it, first by trying
to find the class in a default namespace, then failing back to
a full path if not found in the default namespace.
"""
import_value = "%s.%s" % (name_space, import_str)
try:
return import_
except ImportError:
return import_
Which will say ImportError: Missing module import_str, but only as a result of failure of the first import in the try-except block, effectively hiding the true reason of the failure.
In other words, if the first import fails for some interesting reasons, some other, possible meaningles import is tried and only it's error is let to propagate.
+++ This bug was initially created as a clone of Bug #1080424 +++
Description of problem:
When having nova-compute alone on a node, I cannot start it (using PYTHONVERBOSE=1 and slightly modified init script for debuging purposes):
2014-03-25 11:10:42.153 10009 INFO nova.virt.driver [-] Loading compute driver 'vmwareapi.
import nova.virt.vmwareapi # directory /usr/lib/
# /usr/lib/
import nova.virt.vmwareapi # precompiled from /usr/lib/
# /usr/lib/
import nova.virt.
# /usr/lib/
import nova.virt.
# /usr/lib/
import nova.virt.
# /usr/lib/
import nova.virt.
# /usr/lib/
import nova.virt.
# /usr/lib/
import nova.virt.
2014-03-25 11:10:42.155 10009 ERROR nova.virt.driver [-] Unable to load the virtualization driver
2014-03-25 11:10:42.155 10009 TRACE nova.virt.driver Traceback (most recent call last):
2014-03-25 11:10:42.155 10009 TRACE nova.virt.driver File "/usr/lib/
2014-03-25 11:10:42.155 10009 TRACE nova.virt.driver virtapi)
2014-03-25 11:10:42.155 10009 TRACE nova.virt.driver File "/usr/lib/
2014-03-25 11:10:42.155 10009 TRACE nova.virt.driver return import_
2014-03-25 11:10:42.155 10009 TRACE nova.virt.driver File "/usr/lib/
2014-03-25 11:10:42.155 10009 TRACE nova.virt.driver __import__(mod_str)
2014-03-25 11:10:42.155 10009 TRACE nova.virt.driver ImportError: No module named vmwareapi
2014-03-25 11:10:42.155 10009 TRACE nova.virt.driver
when trying to imprort it in ipython:
In [1]: import nova.virt.vmwareapi
-------
ImportError Traceback (most recent call last)
<ipython-
----> 1 import nova.virt.vmwareapi
/usr/lib/
19 """
20 # NOTE(sdague) for nicer compute_driver specification
---> 21 from nova.virt.vmwareapi import driver
22
23 VMwareESXDriver = driver.
/usr/lib/
37 from nova.virt.vmwareapi import error_util
38 from nova.virt.vmwareapi import host
---> 39 from nova.virt.vmwareapi import vim
40 from nova.virt.vmwareapi import vim_util
41 from nova.virt.vmwareapi import vm_util
/usr/lib/
25
26 from oslo.config import cfg
---> 27 import suds
28
29 from nova.openstack.
ImportError: No module named suds
Version-Release number of selected component (if applicable):
openstack-
python-
How reproducible:
always
Steps to Reproduce:
1. Install nova-compute
2. do the import in the python interpret
Actual results:
ImportError: No module named suds
Expected results:
no problem
Additional info:
affects: | python-keystoneclient → nova |
tags: | added: compute |
tags: |
added: oslo removed: compute |
affects: | oslo-incubator → oslo.utils |
Bug 1080435 - messages when the module import fails are very misleading and not descriptive