From 84e4c2b2204d05ec16b63f7ac628da62a20b38d9 Mon Sep 17 00:00:00 2001 From: Tom Swanson Date: Mon, 10 Oct 2016 14:28:49 -0500 Subject: [PATCH] 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 --- .../unit/volume/drivers/dell/test_dellsc.py | 22 ++++++++++++++----- .../drivers/dell/dell_storagecenter_api.py | 3 ++- .../drivers/dell/dell_storagecenter_common.py | 3 ++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/dell/test_dellsc.py b/cinder/tests/unit/volume/drivers/dell/test_dellsc.py index 2350e0a213c..0ab3adf1e86 100644 --- a/cinder/tests/unit/volume/drivers/dell/test_dellsc.py +++ b/cinder/tests/unit/volume/drivers/dell/test_dellsc.py @@ -515,9 +515,10 @@ class DellSCSanISCSIDriverTestCase(test.TestCase): mock_open_connection, mock_init): backends = self.driver.backends - vol = {'id': fake.VOLUME_ID} + vol = {'id': fake.VOLUME_ID, + 'provider_id': '101.101'} mock_api = mock.MagicMock() - sclivevol = {'instanceId': '101.101', + sclivevol = {'instanceId': '101.102', 'secondaryVolume': {'instanceId': '102.101', 'instanceName': fake.VOLUME_ID}, 'secondaryScSerialNumber': 102, @@ -525,23 +526,34 @@ class DellSCSanISCSIDriverTestCase(test.TestCase): mock_api.get_live_volume = mock.MagicMock(return_value=sclivevol) # No replication driver data. ret = self.driver._delete_live_volume(mock_api, vol) + self.assertFalse(mock_api.get_live_volume.called) self.assertFalse(ret) # 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) + self.assertFalse(mock_api.get_live_volume.called) self.assertFalse(ret) # Valid delete. 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) + mock_api.get_live_volume.assert_called_with('101.101', fake.VOLUME_ID) self.assertTrue(ret) # 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) + mock_api.get_live_volume.assert_called_with('101.101', fake.VOLUME_ID) self.assertFalse(ret) # No live volume found. mock_api.get_live_volume.return_value = None 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.driver.backends = backends diff --git a/cinder/volume/drivers/dell/dell_storagecenter_api.py b/cinder/volume/drivers/dell/dell_storagecenter_api.py index 423f097882a..3f71a5ef7c9 100644 --- a/cinder/volume/drivers/dell/dell_storagecenter_api.py +++ b/cinder/volume/drivers/dell/dell_storagecenter_api.py @@ -3133,7 +3133,7 @@ class StorageCenterApi(object): """Get's the live ScLiveVolume object for the vol with primaryid. :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 """ sclivevol = None @@ -3158,6 +3158,7 @@ class StorageCenterApi(object): if (name and sclivevol is None and lv['instanceName'].endswith(name)): sclivevol = lv + LOG.debug('get_live_volume: %r', sclivevol) return sclivevol def _get_hbas(self, serverid): diff --git a/cinder/volume/drivers/dell/dell_storagecenter_common.py b/cinder/volume/drivers/dell/dell_storagecenter_common.py index 0df2364279a..3a25407b5e6 100644 --- a/cinder/volume/drivers/dell/dell_storagecenter_common.py +++ b/cinder/volume/drivers/dell/dell_storagecenter_common.py @@ -365,7 +365,8 @@ class DellCommonDriver(driver.ConsistencyGroupVD, driver.ManageableVD, ssnstrings = self._split_driver_data(replication_driver_data) if ssnstrings: 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? if (sclivevolume and sclivevolume.get('secondaryScSerialNumber') == ssn and