Merge "Log original dropped exception when a new exception occurs"
This commit is contained in:
commit
005db2d7d4
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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'):
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user