Dell SC: Live Volumes not cleaned up

When a volume is deleted after failover/failback some
live volumes might not be found and could be orphaned.

Change-Id: If28cf815f8c9b0ad02bf5a58c97c265da35dcf98
Closes-Bug: #1632069
This commit is contained in:
Tom Swanson 2016-10-10 14:28:49 -05:00
parent 41b516234f
commit 84e4c2b220
3 changed files with 21 additions and 7 deletions

View File

@ -515,9 +515,10 @@ class DellSCSanISCSIDriverTestCase(test.TestCase):
mock_open_connection, mock_open_connection,
mock_init): mock_init):
backends = self.driver.backends backends = self.driver.backends
vol = {'id': fake.VOLUME_ID} vol = {'id': fake.VOLUME_ID,
'provider_id': '101.101'}
mock_api = mock.MagicMock() mock_api = mock.MagicMock()
sclivevol = {'instanceId': '101.101', sclivevol = {'instanceId': '101.102',
'secondaryVolume': {'instanceId': '102.101', 'secondaryVolume': {'instanceId': '102.101',
'instanceName': fake.VOLUME_ID}, 'instanceName': fake.VOLUME_ID},
'secondaryScSerialNumber': 102, 'secondaryScSerialNumber': 102,
@ -525,23 +526,34 @@ class DellSCSanISCSIDriverTestCase(test.TestCase):
mock_api.get_live_volume = mock.MagicMock(return_value=sclivevol) mock_api.get_live_volume = mock.MagicMock(return_value=sclivevol)
# No replication driver data. # No replication driver data.
ret = self.driver._delete_live_volume(mock_api, vol) ret = self.driver._delete_live_volume(mock_api, vol)
self.assertFalse(mock_api.get_live_volume.called)
self.assertFalse(ret) self.assertFalse(ret)
# Bogus rdd # Bogus rdd
vol = {'id': fake.VOLUME_ID, 'replication_driver_data': ''} vol = {'id': fake.VOLUME_ID,
'provider_id': '101.101',
'replication_driver_data': ''}
ret = self.driver._delete_live_volume(mock_api, vol) ret = self.driver._delete_live_volume(mock_api, vol)
self.assertFalse(mock_api.get_live_volume.called)
self.assertFalse(ret) self.assertFalse(ret)
# Valid delete. # Valid delete.
mock_api.delete_live_volume = mock.MagicMock(return_value=True) mock_api.delete_live_volume = mock.MagicMock(return_value=True)
vol = {'id': fake.VOLUME_ID, 'replication_driver_data': '102'} vol = {'id': fake.VOLUME_ID,
'provider_id': '101.101',
'replication_driver_data': '102'}
ret = self.driver._delete_live_volume(mock_api, vol) ret = self.driver._delete_live_volume(mock_api, vol)
mock_api.get_live_volume.assert_called_with('101.101', fake.VOLUME_ID)
self.assertTrue(ret) self.assertTrue(ret)
# Wrong ssn. # Wrong ssn.
vol = {'id': fake.VOLUME_ID, 'replication_driver_data': '103'} vol = {'id': fake.VOLUME_ID,
'provider_id': '101.101',
'replication_driver_data': '103'}
ret = self.driver._delete_live_volume(mock_api, vol) ret = self.driver._delete_live_volume(mock_api, vol)
mock_api.get_live_volume.assert_called_with('101.101', fake.VOLUME_ID)
self.assertFalse(ret) self.assertFalse(ret)
# No live volume found. # No live volume found.
mock_api.get_live_volume.return_value = None mock_api.get_live_volume.return_value = None
ret = self.driver._delete_live_volume(mock_api, vol) ret = self.driver._delete_live_volume(mock_api, vol)
mock_api.get_live_volume.assert_called_with('101.101', fake.VOLUME_ID)
self.assertFalse(ret) self.assertFalse(ret)
self.driver.backends = backends self.driver.backends = backends

View File

@ -3133,7 +3133,7 @@ class StorageCenterApi(object):
"""Get's the live ScLiveVolume object for the vol with primaryid. """Get's the live ScLiveVolume object for the vol with primaryid.
:param primaryid: InstanceId of the primary volume. :param primaryid: InstanceId of the primary volume.
:parma name: Volume name associated with this live volume. :param name: Volume name associated with this live volume.
:return: ScLiveVolume object or None :return: ScLiveVolume object or None
""" """
sclivevol = None sclivevol = None
@ -3158,6 +3158,7 @@ class StorageCenterApi(object):
if (name and sclivevol is None and if (name and sclivevol is None and
lv['instanceName'].endswith(name)): lv['instanceName'].endswith(name)):
sclivevol = lv sclivevol = lv
LOG.debug('get_live_volume: %r', sclivevol)
return sclivevol return sclivevol
def _get_hbas(self, serverid): def _get_hbas(self, serverid):

View File

@ -365,7 +365,8 @@ class DellCommonDriver(driver.ConsistencyGroupVD, driver.ManageableVD,
ssnstrings = self._split_driver_data(replication_driver_data) ssnstrings = self._split_driver_data(replication_driver_data)
if ssnstrings: if ssnstrings:
ssn = int(ssnstrings[0]) ssn = int(ssnstrings[0])
sclivevolume = api.get_live_volume(volume.get('provider_id')) sclivevolume = api.get_live_volume(volume.get('provider_id'),
volume.get('id'))
# Have we found the live volume? # Have we found the live volume?
if (sclivevolume and if (sclivevolume and
sclivevolume.get('secondaryScSerialNumber') == ssn and sclivevolume.get('secondaryScSerialNumber') == ssn and