summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2011-11-03 17:28:43 +0000
committerGerrit Code Review <review@openstack.org>2011-11-03 17:28:43 +0000
commit005db2d7d494115c05b68875dcf222a68abc0957 (patch)
treec1c48cdbe6696fd418592d80ee66b061bab209e4
parent05370d0aa85d0ecb7d51098ca0c42d96777e3a20 (diff)
parente2403739d5e866e011ecc45a4d5b20d5e0192997 (diff)
downloadnova-005db2d7d494115c05b68875dcf222a68abc0957.tar.gz
nova-005db2d7d494115c05b68875dcf222a68abc0957.tar.xz
nova-005db2d7d494115c05b68875dcf222a68abc0957.zip
Merge "Log original dropped exception when a new exception occurs"
-rw-r--r--nova/compute/manager.py2
-rw-r--r--nova/exception.py2
-rw-r--r--nova/utils.py22
-rw-r--r--nova/virt/xenapi/vm_utils.py2
4 files changed, 18 insertions, 10 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index b1e75cd9a..ddd878664 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -470,7 +470,7 @@ class ComputeManager(manager.SchedulerDependentManager):
# be fixed once we have no-db-messaging
pass
except:
- with utils.original_exception_raised():
+ with utils.save_and_reraise_exception():
_deallocate_network()
def _get_instance_volume_bdms(self, context, instance_id):
diff --git a/nova/exception.py b/nova/exception.py
index 5906c3aa5..1b80a0f56 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -107,6 +107,8 @@ def wrap_exception(notifier=None, publisher_id=None, event_type=None,
# TODO(sandy): Find a way to import nova.notifier.api so we don't have
# to pass it in as a parameter. Otherwise we get a cyclic import of
# nova.notifier.api -> nova.utils -> nova.exception :(
+ # TODO(johannes): Also, it would be nice to use
+ # utils.save_and_reraise_exception() without an import loop
def inner(f):
def wrapped(*args, **kw):
try:
diff --git a/nova/utils.py b/nova/utils.py
index 9a01a6fb8..655be744d 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -979,21 +979,27 @@ def generate_glance_url():
@contextlib.contextmanager
-def original_exception_raised():
- """Run some code, then re-raise the original exception.
+def save_and_reraise_exception():
+ """Save current exception, run some code and then re-raise.
- This is needed because when Eventlet switches greenthreads, it clears the
- exception context. This means if exception handler code blocks, we'll lose
- the helpful exception traceback information.
+ In some cases the exception context can be cleared, resulting in None
+ being attempted to be reraised after an exception handler is run. This
+ can happen when eventlet switches greenthreads or when running an
+ exception handler, code raises and catches and exception. In both
+ cases the exception context will be cleared.
To work around this, we save the exception state, run handler code, and
- then re-raise the original exception.
+ then re-raise the original exception. If another exception occurs, the
+ saved exception is logged and the new exception is reraised.
"""
type_, value, traceback = sys.exc_info()
try:
yield
- finally:
- raise type_, value, traceback
+ except:
+ LOG.exception(_('Original exception being dropped'),
+ exc_info=(type_, value, traceback))
+ raise
+ raise type_, value, traceback
def make_dev_path(dev, partition=None, base='/dev'):
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 18ab0444b..296f9b0e4 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -505,7 +505,7 @@ w
cls.create_vbd(session, vm_ref, vdi_ref, userdevice,
bootable=False)
except:
- with utils.original_exception_raised():
+ with utils.save_and_reraise_exception():
cls.destroy_vdi(session, vdi_ref)
@classmethod