From efe9dfb685321a4dfa8d3444f3a88a554b826a00 Mon Sep 17 00:00:00 2001 From: katarimanojkumar Date: Sun, 9 Aug 2020 17:39:09 +0000 Subject: [PATCH] [storwize]:Fixed check_flashcopy_rate issues Fixed issues in check_flashcopy_rate that impacts the performance during bulk Group Snapshot/Clone operations. check_flashcopy_rate will not make lssystem calls everytime, instead it uses code_level. closes bug: #1890586 Change-Id: Icae65dd2473340450c1ff4135f1da86a884ea545 --- .../volume/drivers/ibm/test_storwize_svc.py | 26 +++++++++++++++++++ .../ibm/storwize_svc/storwize_svc_common.py | 11 +++++--- ...k_flashcopy_rate-fix-571e6e182b604725.yaml | 7 +++++ 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/bug-1890586-storwize-check_flashcopy_rate-fix-571e6e182b604725.yaml diff --git a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py index 31e9c3d4053..8c2dd4e4e15 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -8364,6 +8364,32 @@ class StorwizeHelpersTestCase(test.TestCase): self.storwize_svc_common.pretreatment_before_revert(vol) stopfcmap.assert_called_once_with('4', split=True) + def test_storwize_check_flashcopy_rate_invalid1(self): + with mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'get_system_info') as get_system_info: + fake_system_info = {'code_level': (7, 6, 0, 0), + 'topology': 'standard', + 'system_name': 'storwize-svc-sim', + 'system_id': '0123456789ABCDEF'} + get_system_info.return_value = fake_system_info + flashcopy_rate = 120 + self.assertRaises(exception.VolumeDriverException, + self.storwize_svc_common.check_flashcopy_rate, + flashcopy_rate) + + def test_storwize_check_flashcopy_rate_invalid2(self): + with mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'get_system_info') as get_system_info: + fake_system_info = {'code_level': (7, 8, 1, 2), + 'topology': 'standard', + 'system_name': 'storwize-svc-sim', + 'system_id': '0123456789ABCDEF'} + get_system_info.return_value = fake_system_info + flashcopy_rate = 200 + self.assertRaises(exception.InvalidInput, + self.storwize_svc_common.check_flashcopy_rate, + flashcopy_rate) + @ddt.ddt class StorwizeSSHTestCase(test.TestCase): diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py index 26c3e9eaaa3..948baf5ff3c 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -747,6 +747,7 @@ class StorwizeHelpers(object): def __init__(self, run_ssh): self.ssh = StorwizeSSH(run_ssh) self.check_fcmapping_interval = 3 + self.code_level = None @staticmethod def handle_keyerror(cmd, out): @@ -1951,18 +1952,20 @@ class StorwizeHelpers(object): return volume_model_updates def check_flashcopy_rate(self, flashcopy_rate): - sys_info = self.get_system_info() - code_level = sys_info['code_level'] + if not self.code_level: + sys_info = self.get_system_info() + self.code_level = sys_info['code_level'] + if flashcopy_rate not in range(1, 151): raise exception.InvalidInput( reason=_('The configured flashcopy rate should be ' 'between 1 and 150.')) - elif code_level < (7, 8, 1, 0) and flashcopy_rate > 100: + elif self.code_level < (7, 8, 1, 0) and flashcopy_rate > 100: msg = (_('The configured flashcopy rate is %(fc_rate)s, The ' 'storage code level is %(code_level)s, the flashcopy_rate' ' range is 1-100 if the storwize code level ' 'below 7.8.1.') % {'fc_rate': flashcopy_rate, - 'code_level': code_level}) + 'code_level': self.code_level}) LOG.error(msg) raise exception.VolumeDriverException(message=msg) diff --git a/releasenotes/notes/bug-1890586-storwize-check_flashcopy_rate-fix-571e6e182b604725.yaml b/releasenotes/notes/bug-1890586-storwize-check_flashcopy_rate-fix-571e6e182b604725.yaml new file mode 100644 index 00000000000..76a5eddacee --- /dev/null +++ b/releasenotes/notes/bug-1890586-storwize-check_flashcopy_rate-fix-571e6e182b604725.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + `Bug #1890586 `_: + IBM Storwize: Fixed issues in check_flashcopy_rate that impacts + the performance during Group Snapshot/Clone operations for bulk + volumes.