summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislaw Pitucha <stanislaw.pitucha@hp.com>2012-09-20 10:23:45 +0100
committerStanislaw Pitucha <stanislaw.pitucha@hp.com>2012-09-21 10:58:20 +0100
commit4c09d809c9bd37eeb55f64ec01f8a0b900f9a3bf (patch)
tree8458db3c935638b5d8b6664a6ea39b010990d2b4
parent075e7888f00c9e614364674534a168c6635e162a (diff)
downloadnova-4c09d809c9bd37eeb55f64ec01f8a0b900f9a3bf.tar.gz
nova-4c09d809c9bd37eeb55f64ec01f8a0b900f9a3bf.tar.xz
nova-4c09d809c9bd37eeb55f64ec01f8a0b900f9a3bf.zip
Cleanup exception handling
Make sure stack traces are not cut short. Make sure there's only one exception handler per function (otherwise new exception covers the old one). Fixes bug 1053421 Change-Id: Id1ff84a5ba3eaeef6385b311773bde784672e1f9
-rw-r--r--nova/api/openstack/compute/contrib/floating_ips.py2
-rw-r--r--nova/virt/hyperv/vmops.py2
-rw-r--r--nova/virt/libvirt/driver.py27
-rw-r--r--nova/virt/xenapi/vm_utils.py2
4 files changed, 19 insertions, 14 deletions
diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py
index f3692e02e..be952eb8a 100644
--- a/nova/api/openstack/compute/contrib/floating_ips.py
+++ b/nova/api/openstack/compute/contrib/floating_ips.py
@@ -175,7 +175,7 @@ class FloatingIPController(object):
nmfi.message = _("No more floating ips in pool %s.") % pool
else:
nmfi.message = _("No more floating ips available.")
- raise nmfi
+ raise
return _translate_floating_ip_view(ip)
diff --git a/nova/virt/hyperv/vmops.py b/nova/virt/hyperv/vmops.py
index af6f9cfbf..8c86016c2 100644
--- a/nova/virt/hyperv/vmops.py
+++ b/nova/virt/hyperv/vmops.py
@@ -157,7 +157,7 @@ class VMOps(baseops.BaseOps):
except Exception as exn:
LOG.exception(_('spawn vm failed: %s'), exn)
self.destroy(instance)
- raise exn
+ raise
def _create_vm(self, instance):
"""Create a VM but don't start it. """
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 567ed6ec8..7e828163c 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -1183,11 +1183,11 @@ class LibvirtDriver(driver.ComputeDriver):
else:
LOG.error(_("Error on '%(path)s' while checking direct I/O: "
"'%(ex)s'") % {'path': dirpath, 'ex': str(e)})
- raise e
+ raise
except Exception, e:
LOG.error(_("Error on '%(path)s' while checking direct I/O: "
"'%(ex)s'") % {'path': dirpath, 'ex': str(e)})
- raise e
+ raise
finally:
try:
os.unlink(testfile)
@@ -2764,6 +2764,16 @@ class LibvirtDriver(driver.ComputeDriver):
"""Manage the local cache of images."""
self.image_cache_manager.verify_base_images(context)
+ def _cleanup_remote_migration(self, dest, inst_base, inst_base_resize):
+ """Used only for cleanup in case migrate_disk_and_power_off fails"""
+ try:
+ if os.path.exists(inst_base_resize):
+ utils.execute('rm', '-rf', inst_base)
+ utils.execute('mv', inst_base_resize, inst_base)
+ utils.execute('ssh', dest, 'rm', '-rf', inst_base)
+ except Exception:
+ pass
+
@exception.wrap_exception()
def migrate_disk_and_power_off(self, context, instance, dest,
instance_type, network_info,
@@ -2816,15 +2826,10 @@ class LibvirtDriver(driver.ComputeDriver):
else: # raw or qcow2 with no backing file
libvirt_utils.copy_image(from_path, img_path, host=dest)
- except Exception, e:
- try:
- if os.path.exists(inst_base_resize):
- utils.execute('rm', '-rf', inst_base)
- utils.execute('mv', inst_base_resize, inst_base)
- utils.execute('ssh', dest, 'rm', '-rf', inst_base)
- except Exception:
- pass
- raise e
+ except Exception:
+ with excutils.save_and_reraise_exception():
+ self._cleanup_remote_migration(dest, inst_base,
+ inst_base_resize)
return disk_info_text
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index 03a86415c..a9adb4575 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -1148,7 +1148,7 @@ def _fetch_disk_image(context, session, instance, name_label, image_id,
e.args = e.args + ([dict(type=ImageType.to_string(image_type),
uuid=vdi_uuid,
file=filename)],)
- raise e
+ raise
def determine_disk_image_type(image_meta):