From 616098dcd36b20e01d38898b8942003df664e6ac Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Fri, 14 Jun 2013 17:53:53 +0400 Subject: Do not raise NEW exceptions Raising NEW exception is bad practice, because we lose TraceBack. So all places like: except SomeException as e: raise e should be replaced by except SomeException: raise If we are doing some other actions before reraising we should store information about exception then do all actions and then reraise it. This is caused by eventlet bug. It lost information about exception if it switch threads. fixes bug 1191730 Change-Id: Ia375ecef9f16bda65d5146d14ed4b37a988abb0c --- nova/virt/baremetal/db/sqlalchemy/api.py | 3 +-- nova/virt/disk/vfs/localfs.py | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/baremetal/db/sqlalchemy/api.py b/nova/virt/baremetal/db/sqlalchemy/api.py index 88d44e3d3..0012745a5 100644 --- a/nova/virt/baremetal/db/sqlalchemy/api.py +++ b/nova/virt/baremetal/db/sqlalchemy/api.py @@ -402,8 +402,7 @@ def bm_interface_set_vif_uuid(context, if_id, vif_uuid): if str(e).find('IntegrityError') != -1: raise exception.NovaException(_("Baremetal interface %s " "already in use") % vif_uuid) - else: - raise e + raise @sqlalchemy_api.require_admin_context diff --git a/nova/virt/disk/vfs/localfs.py b/nova/virt/disk/vfs/localfs.py index 10b9a1aa8..735481340 100644 --- a/nova/virt/disk/vfs/localfs.py +++ b/nova/virt/disk/vfs/localfs.py @@ -18,6 +18,7 @@ import os import tempfile from nova import exception +from nova.openstack.common import excutils from nova.openstack.common import log as logging from nova import utils from nova.virt.disk.mount import loop @@ -77,10 +78,9 @@ class VFSLocalFS(vfs.VFS): raise exception.NovaException(mount.error) self.mount = mount except Exception as e: - LOG.debug(_("Failed to mount image %(ex)s)") % - {'ex': str(e)}) - self.teardown() - raise e + with excutils.save_and_reraise_exception(): + LOG.debug(_("Failed to mount image %(ex)s)"), {'ex': str(e)}) + self.teardown() def teardown(self): try: -- cgit