Merge "[SVF]:Reduce slowness by caching pool information"

This commit is contained in:
Zuul 2020-10-01 01:43:36 +00:00 committed by Gerrit Code Review
commit 918e913def
3 changed files with 69 additions and 1 deletions

View File

@ -5537,7 +5537,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
self._set_flag('reserved_percentage', 25) self._set_flag('reserved_percentage', 25)
self._set_flag('storwize_svc_multihostmap_enabled', True) self._set_flag('storwize_svc_multihostmap_enabled', True)
self._set_flag('storwize_svc_vol_rsize', rsize) 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']: for each_pool in stats['pools']:
self.assertIn(each_pool['pool_name'], self.assertIn(each_pool['pool_name'],
self._def_flags['storwize_svc_volpool_name']) self._def_flags['storwize_svc_volpool_name'])
@ -8269,6 +8269,7 @@ port_speed!8Gb
list(resp.select('port_id', 'port_status'))) list(resp.select('port_id', 'port_status')))
@ddt.ddt
class StorwizeHelpersTestCase(test.TestCase): class StorwizeHelpersTestCase(test.TestCase):
def setUp(self): def setUp(self):
super(StorwizeHelpersTestCase, self).setUp() super(StorwizeHelpersTestCase, self).setUp()
@ -8522,6 +8523,35 @@ class StorwizeHelpersTestCase(test.TestCase):
self.storwize_svc_common.check_flashcopy_rate, self.storwize_svc_common.check_flashcopy_rate,
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 @ddt.ddt
class StorwizeSSHTestCase(test.TestCase): class StorwizeSSHTestCase(test.TestCase):

View File

@ -756,6 +756,7 @@ class StorwizeHelpers(object):
self.ssh = StorwizeSSH(run_ssh) self.ssh = StorwizeSSH(run_ssh)
self.check_fcmapping_interval = 3 self.check_fcmapping_interval = 3
self.code_level = None self.code_level = None
self.stats = {}
@staticmethod @staticmethod
def handle_keyerror(cmd, out): def handle_keyerror(cmd, out):
@ -825,6 +826,12 @@ class StorwizeHelpers(object):
def is_data_reduction_pool(self, pool_name): def is_data_reduction_pool(self, pool_name):
"""Check if pool is data reduction pool.""" """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) pool_data = self.get_pool_attrs(pool_name)
if (pool_data and 'data_reduction' in pool_data and if (pool_data and 'data_reduction' in pool_data and
pool_data['data_reduction'] == 'yes'): pool_data['data_reduction'] == 'yes'):
@ -2778,6 +2785,9 @@ class StorwizeSVCCommonDriver(san.SanDriver,
# This is used to save the available pools in failed-over status # This is used to save the available pools in failed-over status
self._secondary_pools = None 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 # Storwize has the limitation that can not burst more than 3 new ssh
# connections within 1 second. So slow down the initialization. # connections within 1 second. So slow down the initialization.
time.sleep(1) time.sleep(1)
@ -2795,6 +2805,12 @@ class StorwizeSVCCommonDriver(san.SanDriver,
# Get list of all volumes # Get list of all volumes
self._get_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 # Build the list of in-progress vdisk copy operations
if ctxt is None: if ctxt is None:
admin_context = context.get_admin_context() admin_context = context.get_admin_context()
@ -3583,6 +3599,8 @@ class StorwizeSVCCommonDriver(san.SanDriver,
self._state = self._master_state self._state = self._master_state
self._update_volume_stats() self._update_volume_stats()
self._master_backend_helpers.stats = self._stats
return storwize_const.FAILBACK_VALUE, volumes_update, groups_update return storwize_const.FAILBACK_VALUE, volumes_update, groups_update
def _failback_replica_volumes(self, ctxt, rep_volumes): def _failback_replica_volumes(self, ctxt, rep_volumes):
@ -3832,6 +3850,8 @@ class StorwizeSVCCommonDriver(san.SanDriver,
self._state = self._aux_state self._state = self._aux_state
self._update_volume_stats() self._update_volume_stats()
self._aux_backend_helpers.stats = self._stats
return self._active_backend_id, volumes_update, groups_update return self._active_backend_id, volumes_update, groups_update
def _failover_replica_volumes(self, ctxt, rep_volumes): def _failover_replica_volumes(self, ctxt, rep_volumes):
@ -5632,6 +5652,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
"""Build pool status""" """Build pool status"""
QoS_support = True QoS_support = True
pool_stats = {} pool_stats = {}
is_dr_pool = False
pool_data = self._helpers.get_pool_attrs(pool) pool_data = self._helpers.get_pool_attrs(pool)
if pool_data: if pool_data:
easy_tier = pool_data['easy_tier'] in ['on', 'auto'] easy_tier = pool_data['easy_tier'] in ['on', 'auto']
@ -5655,6 +5676,14 @@ class StorwizeSVCCommonDriver(san.SanDriver,
storwize_svc_multihostmap_enabled) storwize_svc_multihostmap_enabled)
backend_state = ('up' if pool_data['status'] == 'online' else backend_state = ('up' if pool_data['status'] == 'online' else
'down') '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_stats = {
'pool_name': pool_data['name'], 'pool_name': pool_data['name'],
'total_capacity_gb': total_capacity_gb, 'total_capacity_gb': total_capacity_gb,
@ -5674,6 +5703,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
'max_over_subscription_ratio': over_sub_ratio, 'max_over_subscription_ratio': over_sub_ratio,
'consistent_group_snapshot_enabled': True, 'consistent_group_snapshot_enabled': True,
'backend_state': backend_state, 'backend_state': backend_state,
'data_reduction': is_dr_pool,
} }
if self._replica_enabled: if self._replica_enabled:
pool_stats.update({ pool_stats.update({
@ -5695,6 +5725,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
'thick_provisioning_support': False, 'thick_provisioning_support': False,
'max_over_subscription_ratio': 0, 'max_over_subscription_ratio': 0,
'reserved_percentage': 0, 'reserved_percentage': 0,
'data_reduction': is_dr_pool,
'backend_state': 'down'} 'backend_state': 'down'}
return pool_stats 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.