From 70a07ee7a2fda6c129903a21431fa2d499f4160d Mon Sep 17 00:00:00 2001 From: katarimanojkumar Date: Wed, 11 Aug 2021 13:25:57 +0000 Subject: [PATCH] [SVF]:Fix create volume on drp [Spectrum Virtualize Family] While creating volumes on data reduction pool, incorrect options were picked. This patch fixes a bug caused by a case sensitive string comparison that caused the code to incorrectly identify whether DRP was enabled in a pool during intialization. Closes-Bug: #1924568 Change-Id: I5a2914d77b85e4249774f6e366b93d8b997ea50f --- .../volume/drivers/ibm/test_storwize_svc.py | 39 +++++++++++++++++++ .../ibm/storwize_svc/storwize_svc_common.py | 6 +-- ...drp_vol_create_issue-d1b75c4befb0e993.yaml | 7 ++++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/bug-1924568-ibm-svf-fix_drp_vol_create_issue-d1b75c4befb0e993.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 0aa8b719f9c..7bd139f5ba1 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -5437,6 +5437,45 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase): if 'CMMVC7050E' not in e.stderr: raise + @ddt.data(('yes'), ('Yes'), ('no'), ('NO'), ('')) + @mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'get_pool_attrs') + def test_build_pool_stats_drp(self, is_drp, get_pool_attrs): + get_pool_attrs.return_value = {'id': 1, 'name': 'openstack', + 'data_reduction': is_drp, + 'easy_tier': 'on', + 'capacity': '20', + 'free_capacity': '40', + 'used_capacity': '0', + 'real_capacity': '0', + 'virtual_capacity': '0', + 'status': 'online', + 'site_id': '1', + 'site_name': 'site1'} + pool = 'openstack' + pool_stats = self.driver._build_pool_stats(pool) + if is_drp in ['yes', 'Yes']: + self.assertTrue(pool_stats['data_reduction']) + else: + self.assertFalse(pool_stats['data_reduction']) + + @mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'get_pool_attrs') + def test_build_pool_stats_drp_none(self, get_pool_attrs): + get_pool_attrs.return_value = {'id': 1, 'name': 'openstack1', + 'easy_tier': 'on', + 'capacity': '20', + 'free_capacity': '40', + 'used_capacity': '0', + 'real_capacity': '0', + 'virtual_capacity': '0', + 'status': 'online', + 'site_id': '1', + 'site_name': 'site1'} + pool = 'openstack1' + pool_stats = self.driver._build_pool_stats(pool) + self.assertFalse(pool_stats['data_reduction']) + @ddt.data(('IOPs_limit', "50"), ('bandwidth_limit_MB', "100")) @mock.patch.object(storwize_svc_common.StorwizeHelpers, 'get_pool_volumes') @mock.patch.object(storwize_svc_common.StorwizeSSH, 'lsthrottle') 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 6613c607138..a01c6aaae17 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -6025,10 +6025,8 @@ class StorwizeSVCCommonDriver(san.SanDriver, # Get the data_reduction information for pool and set # is_dr_pool flag. - if pool_data.get('data_reduction') == 'Yes': - is_dr_pool = True - elif pool_data.get('data_reduction') == 'No': - is_dr_pool = False + if pool_data.get('data_reduction'): + is_dr_pool = pool_data.get('data_reduction').lower() == 'yes' pool_stats = { 'pool_name': pool_data['name'], diff --git a/releasenotes/notes/bug-1924568-ibm-svf-fix_drp_vol_create_issue-d1b75c4befb0e993.yaml b/releasenotes/notes/bug-1924568-ibm-svf-fix_drp_vol_create_issue-d1b75c4befb0e993.yaml new file mode 100644 index 00000000000..6d2ad96a84c --- /dev/null +++ b/releasenotes/notes/bug-1924568-ibm-svf-fix_drp_vol_create_issue-d1b75c4befb0e993.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + IBM Spectrum Virtualize Family driver + `Bug #1924568 `_: + Fixed issues that occurred while creating volume on data reduction + pool.