Catch iscsi VolumeDeviceNotFound when detaching
If exceptions are raised, nova-compute can't start when executing _destroy_evacuated_instances. Change-Id: I0a2877ec0f922d2bc9a742d1c2c2540a6b77e9ce Closes-Bug: #1532657
This commit is contained in:
parent
550a150b52
commit
007137e9ef
|
@ -11,6 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
import mock
|
||||
from os_brick import exception as os_brick_exception
|
||||
from os_brick.initiator import connector
|
||||
|
||||
from nova.tests.unit.virt.libvirt.volume import test_volume
|
||||
|
@ -88,3 +89,18 @@ Setting up iSCSI targets: unused
|
|||
self.assertEqual(device_path, tree.find('./source').get('dev'))
|
||||
self.assertEqual('raw', tree.find('./driver').get('type'))
|
||||
self.assertEqual('native', tree.find('./driver').get('io'))
|
||||
|
||||
@mock.patch.object(iscsi.LOG, 'warning')
|
||||
def test_libvirt_iscsi_driver_disconnect_volume_with_devicenotfound(self,
|
||||
mock_LOG_warning):
|
||||
device_path = '/dev/fake-dev'
|
||||
connection_info = {'data': {'device_path': device_path}}
|
||||
|
||||
libvirt_driver = iscsi.LibvirtISCSIVolumeDriver(self.fake_conn)
|
||||
libvirt_driver.connector.disconnect_volume = mock.MagicMock(
|
||||
side_effect=os_brick_exception.VolumeDeviceNotFound(
|
||||
device=device_path))
|
||||
libvirt_driver.disconnect_volume(connection_info, device_path)
|
||||
|
||||
msg = mock_LOG_warning.call_args_list[0]
|
||||
self.assertIn('Ignoring VolumeDeviceNotFound', msg[0][0])
|
||||
|
|
|
@ -11,10 +11,12 @@
|
|||
# under the License.
|
||||
"""Libvirt volume driver for iSCSI"""
|
||||
|
||||
from os_brick import exception as os_brick_exception
|
||||
from os_brick.initiator import connector
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from nova.i18n import _LW
|
||||
from nova import utils
|
||||
from nova.virt.libvirt.volume import volume as libvirt_volume
|
||||
|
||||
|
@ -91,7 +93,11 @@ class LibvirtISCSIVolumeDriver(libvirt_volume.LibvirtBaseVolumeDriver):
|
|||
"""Detach the volume from instance_name."""
|
||||
|
||||
LOG.debug("calling os-brick to detach iSCSI Volume")
|
||||
self.connector.disconnect_volume(connection_info['data'], None)
|
||||
try:
|
||||
self.connector.disconnect_volume(connection_info['data'], None)
|
||||
except os_brick_exception.VolumeDeviceNotFound as exc:
|
||||
LOG.warning(_LW('Ignoring VolumeDeviceNotFound: %s'), exc)
|
||||
return
|
||||
LOG.debug("Disconnected iSCSI Volume %s", disk_dev)
|
||||
|
||||
super(LibvirtISCSIVolumeDriver,
|
||||
|
|
Loading…
Reference in New Issue