Fix Share Migration KeyError on dict.pop
In Share migration it is always trying to remove the Copy object from dictionary, even if it has not been added yet. So, dict.pop() should include second argument to not throw exception. Improved unit test to cover this variation. Closes-bug: #1555630 Change-Id: If81c14cbeb03e41501d825cab000ceb1aa2cae7c
This commit is contained in:
parent
cdab09b822
commit
b8e9ae892a
@ -104,7 +104,7 @@ class DataManager(manager.Manager):
|
||||
context, share_ref, share_instance_id, dest_share_instance_id)
|
||||
raise exception.ShareDataCopyFailed(reason=msg)
|
||||
finally:
|
||||
self.busy_tasks_shares.pop(share_id)
|
||||
self.busy_tasks_shares.pop(share_id, None)
|
||||
|
||||
LOG.info(_LI(
|
||||
"Completed copy operation of migrating share content from share "
|
||||
|
@ -86,7 +86,8 @@ class DataManagerTestCase(test.TestCase):
|
||||
self.mock_object(data_utils, 'Copy',
|
||||
mock.Mock(return_value='fake_copy'))
|
||||
|
||||
self.manager.busy_tasks_shares[self.share['id']] = 'fake_copy'
|
||||
if exc is None:
|
||||
self.manager.busy_tasks_shares[self.share['id']] = 'fake_copy'
|
||||
|
||||
self.mock_object(self.manager, '_copy_share_data',
|
||||
mock.Mock(side_effect=exc))
|
||||
|
Loading…
Reference in New Issue
Block a user