Browse Source

Merge "PowerMax Driver - Miscellaneous improvements to delete"

changes/55/681655/1
Zuul 1 week ago
parent
commit
e2f0a59b2a

+ 14
- 2
cinder/tests/unit/volume/drivers/dell_emc/powermax/test_powermax_common.py View File

@@ -1023,8 +1023,7 @@ class PowerMaxCommonTest(test.TestCase):
1023 1023
             self.assertRaises(exception.VolumeBackendAPIException,
1024 1024
                               self.common._delete_from_srp, array,
1025 1025
                               device_id, volume_name, extra_specs)
1026
-            mock_add.assert_called_once_with(
1027
-                array, device_id, volume_name, extra_specs)
1026
+            mock_add.assert_not_called()
1028 1027
 
1029 1028
     @mock.patch.object(utils.PowerMaxUtils, 'is_replication_enabled',
1030 1029
                        side_effect=[False, True])
@@ -2793,3 +2792,16 @@ class PowerMaxCommonTest(test.TestCase):
2793 2792
     def test_get_replication_info(self, mock_config):
2794 2793
         self.common._get_replication_info()
2795 2794
         mock_config.assert_not_called()
2795
+
2796
+    @mock.patch.object(common.PowerMaxCommon,
2797
+                       '_do_sync_check')
2798
+    def test_sync_check_no_source_device_on_array(self, mock_check):
2799
+        with mock.patch.object(self.rest, 'get_volume',
2800
+                               side_effect=exception.VolumeBackendAPIException(
2801
+                                   "404 00123 does not exist")):
2802
+            array = self.data.array
2803
+            device_id = self.data.device_id
2804
+            extra_specs = self.data.extra_specs
2805
+            self.common._sync_check(array, device_id, extra_specs,
2806
+                                    source_device_id='00123')
2807
+            mock_check.assert_not_called()

+ 17
- 11
cinder/volume/drivers/dell_emc/powermax/common.py View File

@@ -1731,11 +1731,9 @@ class PowerMaxCommon(object):
1731 1731
                 foundsnap_name = None
1732 1732
 
1733 1733
         if foundsnap_name is None or sourcedevice_id is None:
1734
-            exception_message = (_("Error retrieving snapshot details. "
1735
-                                   "Snapshot name: %(snap)s") %
1736
-                                 {'snap': volume_name})
1737
-            LOG.error(exception_message)
1738
-
1734
+            LOG.debug("Error retrieving snapshot details. "
1735
+                      "Snapshot name: %(snap)s",
1736
+                      {'snap': volume_name})
1739 1737
         else:
1740 1738
             LOG.debug("Source volume: %(volume_name)s  Snap name: "
1741 1739
                       "%(foundsnap_name)s.",
@@ -1801,6 +1799,12 @@ class PowerMaxCommon(object):
1801 1799
         # Remove from any storage groups and cleanup replication
1802 1800
         self._remove_vol_and_cleanup_replication(
1803 1801
             array, device_id, volume_name, extra_specs, volume)
1802
+        # Check if volume is in any storage group
1803
+        sg_list = self.rest.get_storage_groups_from_volume(array, device_id)
1804
+        if sg_list:
1805
+            LOG.error("Device %(device_id)s is in storage group(s) "
1806
+                      "%(sg_list)s prior to delete. Delete will fail.",
1807
+                      {'device_id': device_id, 'sg_list': sg_list})
1804 1808
         self._delete_from_srp(
1805 1809
             array, device_id, volume_name, extra_specs)
1806 1810
         return volume_name
@@ -1997,12 +2001,6 @@ class PowerMaxCommon(object):
1997 2001
             self.provision.delete_volume_from_srp(
1998 2002
                 array, device_id, volume_name)
1999 2003
         except Exception as e:
2000
-            # If we cannot successfully delete the volume, then we want to
2001
-            # return the volume to the default storage group,
2002
-            # which should be the SG it previously belonged to.
2003
-            self.masking.add_volume_to_default_storage_group(
2004
-                array, device_id, volume_name, extra_specs)
2005
-
2006 2004
             error_message = (_("Failed to delete volume %(volume_name)s. "
2007 2005
                                "Exception received: %(e)s") %
2008 2006
                              {'volume_name': volume_name,
@@ -2233,6 +2231,14 @@ class PowerMaxCommon(object):
2233 2231
         if source_device_id:
2234 2232
             @coordination.synchronized("emc-source-{source_device_id}")
2235 2233
             def do_unlink_and_delete_snap(source_device_id):
2234
+                # Check if source device exists on the array
2235
+                try:
2236
+                    self.rest.get_volume(array, source_device_id)
2237
+                except exception.VolumeBackendAPIException:
2238
+                    LOG.debug("Device %(device_id)s not found on array, no "
2239
+                              "sync check required.",
2240
+                              {'device_id': source_device_id})
2241
+                    return
2236 2242
                 self._do_sync_check(
2237 2243
                     array, device_id, extra_specs, tgt_only)
2238 2244
 

+ 8
- 5
cinder/volume/drivers/dell_emc/powermax/masking.py View File

@@ -1338,15 +1338,18 @@ class PowerMaxMasking(object):
1338 1338
             self.add_volume_to_default_storage_group(
1339 1339
                 serial_number, device_id, volume_name,
1340 1340
                 extra_specs, src_sg=storagegroup_name)
1341
+            LOG.debug(
1342
+                "Volume %(volume_name)s successfully added to "
1343
+                "storage group %(sg)s.",
1344
+                {'volume_name': volume_name, 'sg': storagegroup_name})
1341 1345
         else:
1342 1346
             self.remove_vol_from_storage_group(
1343 1347
                 serial_number, device_id, storagegroup_name,
1344 1348
                 volume_name, extra_specs)
1345
-
1346
-        LOG.debug(
1347
-            "Volume %(volume_name)s successfully moved/ removed from "
1348
-            "storage group %(sg)s.",
1349
-            {'volume_name': volume_name, 'sg': storagegroup_name})
1349
+            LOG.debug(
1350
+                "Volume %(volume_name)s successfully removed from "
1351
+                "storage group %(sg)s.",
1352
+                {'volume_name': volume_name, 'sg': storagegroup_name})
1350 1353
 
1351 1354
         num_vol_in_sg = self.rest.get_num_vols_in_sg(
1352 1355
             serial_number, storagegroup_name)

+ 1
- 0
cinder/volume/drivers/dell_emc/powermax/rest.py View File

@@ -517,6 +517,7 @@ class PowerMaxRest(object):
517 517
         self.check_status_code_success(operation, status_code, message)
518 518
         return status_code, message
519 519
 
520
+    @retry(retry_exc_tuple, interval=2, retries=3)
520 521
     def delete_resource(
521 522
             self, array, category, resource_type, resource_name,
522 523
             payload=None, private='', params=None):

Loading…
Cancel
Save