]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Storwize/SVC driver crashes when check volume copy status
authorLi Min Liu <liminliu@cn.ibm.com>
Tue, 8 Apr 2014 02:18:56 +0000 (10:18 +0800)
committerThomas Goirand <thomas@goirand.fr>
Mon, 9 Jun 2014 14:08:51 +0000 (22:08 +0800)
Storwize/SVC driver does not clear up property of _vdiskcopyops
when deleting a volume. So if a volume which under async copy is
deleted before sync completed, the driver will crash.

When delete a volume, add a check for _vdiskcopyops, if volume
is in the dict, remove it.

Change-Id: I4905404b72a7ac8f90bd92fa4345ba771a78418b
Closes-Bug: #1304115
(cherry picked from commit 0c4a94eac94399a524ff758fa7046e98b07951ae)

cinder/tests/test_storwize_svc.py
cinder/volume/drivers/ibm/storwize_svc/__init__.py

index cce280a6d0918127a99c5b983c1210fbbc5405b4..53a51317bc6f7021ca7835e215cd03e4436ced79 100644 (file)
@@ -1775,7 +1775,8 @@ class StorwizeSVCDriverTestCase(test.TestCase):
                           volume)
 
         # Try to delete a volume that doesn't exist (should not fail)
-        vol_no_exist = {'name': 'i_dont_exist'}
+        vol_no_exist = {'name': 'i_dont_exist',
+                        'id': '111111'}
         self.driver.delete_volume(vol_no_exist)
         # Ensure export for volume that doesn't exist (should not fail)
         self.driver.ensure_export(None, vol_no_exist)
@@ -2388,6 +2389,14 @@ class StorwizeSVCDriverTestCase(test.TestCase):
                          'Storwize driver delete vdisk copy error')
         self._delete_volume(volume)
 
+    def test_storwize_delete_with_vdisk_copy_ops(self):
+        volume = self._create_volume()
+        self.driver._vdiskcopyops = {volume['id']: [('0', '1')]}
+        with mock.patch.object(self.driver, '_vdiskcopyops_loop'):
+            self.assertIn(volume['id'], self.driver._vdiskcopyops)
+            self.driver.delete_volume(volume)
+            self.assertNotIn(volume['id'], self.driver._vdiskcopyops)
+
     def test_storwize_initiator_target_map(self):
         # Create two volumes to be used in mappings
         ctxt = context.get_admin_context()
index 9011bc8d16a83bf8fa70ec56aa5689e821064f4c..5f5542910d271441f777f7b6036ce53478311e1d 100644 (file)
@@ -493,6 +493,13 @@ class StorwizeSVCDriver(san.SanDriver):
     def delete_volume(self, volume):
         self._helpers.delete_vdisk(volume['name'], False)
 
+        if volume['id'] in self._vdiskcopyops:
+            del self._vdiskcopyops[volume['id']]
+
+            if not len(self._vdiskcopyops):
+                self._vdiskcopyops_loop.stop()
+                self._vdiskcopyops_loop = None
+
     def create_snapshot(self, snapshot):
         ctxt = context.get_admin_context()
         try: