From cb6ce8740131189f79472b6d07c6a02e117d6d53 Mon Sep 17 00:00:00 2001 From: Li Min Liu Date: Tue, 8 Apr 2014 10:18:56 +0800 Subject: [PATCH] Storwize/SVC driver crashes when check volume copy status 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 | 11 ++++++++++- cinder/volume/drivers/ibm/storwize_svc/__init__.py | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cinder/tests/test_storwize_svc.py b/cinder/tests/test_storwize_svc.py index cce280a6d..53a51317b 100644 --- a/cinder/tests/test_storwize_svc.py +++ b/cinder/tests/test_storwize_svc.py @@ -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() diff --git a/cinder/volume/drivers/ibm/storwize_svc/__init__.py b/cinder/volume/drivers/ibm/storwize_svc/__init__.py index 9011bc8d1..5f5542910 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/__init__.py +++ b/cinder/volume/drivers/ibm/storwize_svc/__init__.py @@ -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: -- 2.45.2