From 5d22ec17c7548f3de85ba9e3ad54ce5799dc5fff Mon Sep 17 00:00:00 2001 From: Patrick East Date: Mon, 29 Sep 2014 10:54:22 -0700 Subject: [PATCH] Fix race condition in ISCSIConnector disconnect_volume MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The list of devices returned by driver.get_all_block_devices() will sometimes contain broken symlinks as the SCSI device has been deleted but the udev rule for the symlink has not yet completed. Adding in a check to os.path.exists() will ensure that we will not consider the broken symlinks as an “in use” device. Change-Id: Ibb869e10976f894f9e18e9edec6739c2c3bea68c Closes-Bug: #1375382 --- cinder/brick/initiator/connector.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cinder/brick/initiator/connector.py b/cinder/brick/initiator/connector.py index b58e726b2..fb7277791 100644 --- a/cinder/brick/initiator/connector.py +++ b/cinder/brick/initiator/connector.py @@ -291,7 +291,8 @@ class ISCSIConnector(InitiatorConnector): {'portal': connection_properties['target_portal'], 'iqn': connection_properties['target_iqn']}) devices = self.driver.get_all_block_devices() - devices = [dev for dev in devices if dev.startswith(device_prefix)] + devices = [dev for dev in devices if dev.startswith(device_prefix) + and os.path.exists(dev)] if not devices: self._disconnect_from_iscsi_portal(connection_properties) -- 2.45.2