Merge "Dell PowerFlex: Added retry after disconnect volume"

This commit is contained in:
Zuul 2024-08-22 15:16:37 +00:00 committed by Gerrit Code Review
commit 59541b0908
3 changed files with 57 additions and 0 deletions
os_brick
initiator/connectors
tests/initiator/connectors
releasenotes/notes

@ -531,6 +531,10 @@ class ScaleIOConnector(base.BaseLinuxConnector):
'err': response['message']})
LOG.error(msg)
raise exception.BrickException(message=msg)
else:
if 'device_path' in connection_properties:
path = connection_properties['device_path']
self._wait_for_remove_volume_path(path)
@utils.connect_volume_undo_prepare_result
def extend_volume(self, connection_properties):
@ -549,3 +553,21 @@ class ScaleIOConnector(base.BaseLinuxConnector):
msg = (_("Error extending ScaleIO volume"))
LOG.error(msg)
raise exception.BrickException(message=msg)
# NOTE: Usually 5 retries is enough to find the volume.
# If there are network issues, it could take much longer. Set
# the max retries to 15 to make sure we can find the volume.
@utils.retry(exception.BrickException,
retries=15,
backoff_rate=1)
def _wait_for_remove_volume_path(self, path):
if os.path.exists(path):
msg = (_("ScaleIO volume %(volume_id)s found "
"after disconnect operation at path %(path)s") %
{'volume_id': self.volume_id, 'path': path})
LOG.debug(msg)
raise exception.BrickException(message=msg)
else:
LOG.info("ScaleIO disconnect volume %(volume_id)s "
"removed at path %(path)s.",
{'volume_id': self.volume_id, 'path': path})

@ -357,3 +357,30 @@ class ScaleIOConnectorTestCase(test_connector.ConnectorTestCase):
scaleio.CONNECTOR_CONF_PATH,
connection_properties['config_group'],
False)
@mock.patch('tenacity.wait_exponential')
@mock.patch.object(os.path, 'exists', return_value=True)
def test_disconnect_volume_wait_for_path_not_removed(self,
path_mock,
wait_mock):
self.fake_connection_properties['device_path'] = ('/dev/'
'disk/by-id/'
'emc-vol-'
'00df72815d3b900f'
'-d4f7289200000023')
self.assertRaises(exception.BrickException,
self.test_disconnect_volume)
wait_mock.assert_called_once_with(multiplier=1, min=0, exp_base=1)
@mock.patch('tenacity.wait_exponential')
@mock.patch.object(os.path, 'exists', return_value=False)
def test_disconnect_volume_wait_for_path_removed(self,
path_mock,
wait_mock):
self.fake_connection_properties['device_path'] = ('/dev/'
'disk/by-id/'
'emc-vol-'
'00df72815d3b900f'
'-d4f7289200000023')
self.test_disconnect_volume()
wait_mock.assert_called_once_with(multiplier=1, min=0, exp_base=1)

@ -0,0 +1,8 @@
---
fixes:
- |
Dell PowerFlex driver `Bug #2034685
<https://bugs.launchpad.net/os-brick/+bug/2034685>`_: Added
a retry mechanism to check if the disconnected device is
actually removed from the host ensuring that subsequent
connections succeed.