Merge "[SVF]:Reduce slowness by caching pool information" into stable/ussuri

This commit is contained in:
Zuul 2021-03-02 21:18:04 +00:00 committed by Gerrit Code Review
commit 42fbb39451
3 changed files with 96 additions and 1 deletions

View File

@ -5532,7 +5532,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
self._set_flag('reserved_percentage', 25)
self._set_flag('storwize_svc_multihostmap_enabled', True)
self._set_flag('storwize_svc_vol_rsize', rsize)
stats = self.driver.get_volume_stats()
stats = self.driver.get_volume_stats(True)
for each_pool in stats['pools']:
self.assertIn(each_pool['pool_name'],
self._def_flags['storwize_svc_volpool_name'])
@ -8143,6 +8143,7 @@ port_speed!8Gb
list(resp.select('port_id', 'port_status')))
@ddt.ddt
class StorwizeHelpersTestCase(test.TestCase):
def setUp(self):
super(StorwizeHelpersTestCase, self).setUp()
@ -8309,6 +8310,61 @@ 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.data(({'mirror_pool': 'openstack2',
'volume_topology': None,
'peer_pool': None}, True, 1),
({'mirror_pool': 'openstack2',
'volume_topology': None,
'peer_pool': None}, False, 2),
({'mirror_pool': None,
'volume_topology': 'hyperswap',
'peer_pool': 'openstack1'}, True, 1),
({'mirror_pool': None,
'volume_topology': 'hyperswap',
'peer_pool': 'openstack1'}, False, 2))
@mock.patch.object(storwize_svc_common.StorwizeHelpers,
'is_data_reduction_pool')
@ddt.unpack
def test_is_volume_type_dr_pools_dr_pool(self, opts, is_drp, call_count,
is_data_reduction_pool):
is_data_reduction_pool.return_value = is_drp
pool = 'openstack'
rep_type = None
rep_target_pool = None
isdrpool = (self.storwize_svc_common.
is_volume_type_dr_pools(pool, opts, rep_type,
rep_target_pool))
self.assertEqual(is_drp, isdrpool)
is_data_reduction_pool.assert_called()
self.assertEqual(call_count, is_data_reduction_pool.call_count)
@ddt.ddt
class StorwizeSSHTestCase(test.TestCase):

View File

@ -744,6 +744,8 @@ class StorwizeHelpers(object):
def __init__(self, run_ssh):
self.ssh = StorwizeSSH(run_ssh)
self.check_fcmapping_interval = 3
self.code_level = None
self.stats = {}
@staticmethod
def handle_keyerror(cmd, out):
@ -812,6 +814,12 @@ class StorwizeHelpers(object):
def is_data_reduction_pool(self, pool_name):
"""Check if pool is data reduction pool."""
# Check pool is data reduction pool or not from pool information
# saved in stats.
for pool in self.stats.get('pools', []):
if pool['pool_name'] == pool_name:
return pool['data_reduction']
pool_data = self.get_pool_attrs(pool_name)
if (pool_data and 'data_reduction' in pool_data and
pool_data['data_reduction'] == 'yes'):
@ -2733,6 +2741,9 @@ class StorwizeSVCCommonDriver(san.SanDriver,
# This is used to save the available pools in failed-over status
self._secondary_pools = None
# This dictionary is used to save pools information.
self._stats = {}
# Storwize has the limitation that can not burst more than 3 new ssh
# connections within 1 second. So slow down the initialization.
time.sleep(1)
@ -2750,6 +2761,12 @@ class StorwizeSVCCommonDriver(san.SanDriver,
# Get list of all volumes
self._get_all_volumes()
# Update the pool stats
self._update_volume_stats()
# Save the pool stats information in helpers class.
self._master_backend_helpers.stats = self._stats
# Build the list of in-progress vdisk copy operations
if ctxt is None:
admin_context = context.get_admin_context()
@ -3520,6 +3537,8 @@ class StorwizeSVCCommonDriver(san.SanDriver,
self._state = self._master_state
self._update_volume_stats()
self._master_backend_helpers.stats = self._stats
return storwize_const.FAILBACK_VALUE, volumes_update, groups_update
def _failback_replica_volumes(self, ctxt, rep_volumes):
@ -3769,6 +3788,8 @@ class StorwizeSVCCommonDriver(san.SanDriver,
self._state = self._aux_state
self._update_volume_stats()
self._aux_backend_helpers.stats = self._stats
return self._active_backend_id, volumes_update, groups_update
def _failover_replica_volumes(self, ctxt, rep_volumes):
@ -5568,6 +5589,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
"""Build pool status"""
QoS_support = True
pool_stats = {}
is_dr_pool = False
pool_data = self._helpers.get_pool_attrs(pool)
if pool_data:
easy_tier = pool_data['easy_tier'] in ['on', 'auto']
@ -5591,6 +5613,14 @@ class StorwizeSVCCommonDriver(san.SanDriver,
storwize_svc_multihostmap_enabled)
backend_state = ('up' if pool_data['status'] == 'online' else
'down')
# 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
pool_stats = {
'pool_name': pool_data['name'],
'total_capacity_gb': total_capacity_gb,
@ -5610,6 +5640,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
'max_over_subscription_ratio': over_sub_ratio,
'consistent_group_snapshot_enabled': True,
'backend_state': backend_state,
'data_reduction': is_dr_pool,
}
if self._replica_enabled:
pool_stats.update({
@ -5631,6 +5662,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
'thick_provisioning_support': False,
'max_over_subscription_ratio': 0,
'reserved_percentage': 0,
'data_reduction': is_dr_pool,
'backend_state': 'down'}
return pool_stats

View File

@ -0,0 +1,7 @@
---
fixes:
- |
`Bug #1890591 <https://bugs.launchpad.net/cinder/+bug/1890591>`_:
IBM Spectrum Virtualize Family: Fixed issue in do_setup of
StorwizeSVCCommonDriver to save pool information in stats
during initialisation.