summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorBoris Pavlovic <boris@pavlovic.me>2013-06-14 17:53:53 +0400
committerBoris Pavlovic <boris@pavlovic.me>2013-06-22 00:09:22 +0400
commit616098dcd36b20e01d38898b8942003df664e6ac (patch)
tree0000b9be01d6c6aa565a687c5490def7075bb0d4 /nova/virt
parentd147af21db2db77f578e527883cf2c68abc56496 (diff)
downloadnova-616098dcd36b20e01d38898b8942003df664e6ac.tar.gz
nova-616098dcd36b20e01d38898b8942003df664e6ac.tar.xz
nova-616098dcd36b20e01d38898b8942003df664e6ac.zip
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
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/baremetal/db/sqlalchemy/api.py3
-rw-r--r--nova/virt/disk/vfs/localfs.py8
2 files changed, 5 insertions, 6 deletions
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: