From a2a9f16889b5b74de0daccab3e5011ad0f4d1e94 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Wed, 10 Apr 2013 19:04:30 +0000 Subject: [PATCH] xenapi: Make _connect_volume exc handler eventlet safe `forget_sr` blocks and so clears the exception state causing the subsequent raise to try to raise `None`, which fails. Fixes bug 1167515 Change-Id: I18562c7389b152a6490d352c5a8d36934288f47d --- nova/virt/xenapi/volumeops.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nova/virt/xenapi/volumeops.py b/nova/virt/xenapi/volumeops.py index add3787a3b..f31284ee32 100644 --- a/nova/virt/xenapi/volumeops.py +++ b/nova/virt/xenapi/volumeops.py @@ -20,6 +20,7 @@ Management class for Storage-related functions (attach, detach, etc). """ from nova import exception +from nova.openstack.common import excutils from nova.openstack.common import log as logging from nova.virt.xenapi import vm_utils from nova.virt.xenapi import volume_utils @@ -92,10 +93,11 @@ class VolumeOps(object): if hotplug: self._session.call_xenapi("VBD.plug", vbd_ref) except Exception: - # NOTE(sirp): Forgetting the SR will have the effect of cleaning up - # the VDI and VBD records, so no need to handle that explicitly. - volume_utils.forget_sr(self._session, sr_ref) - raise + with excutils.save_and_reraise_exception(): + # NOTE(sirp): Forgetting the SR will have the effect of + # cleaning up the VDI and VBD records, so no need to handle + # that explicitly. + volume_utils.forget_sr(self._session, sr_ref) def detach_volume(self, connection_info, instance_name, mountpoint): """Detach volume storage to VM instance."""