Use cached values for stats on query failures for vmem drivers

This change allows vmem drivers to return previously cached
values for free_capacity_gb and total_capacity_gb if the queries
to the backend for those stats succeed but do not contain
the data.  This can happen when the mgmt plane is under heavy load.

Change-Id: I218a54897361d739c04963b4c36d93620be01fb3
Closes-Bug: 1433990
This commit is contained in:
Ryan Lucio 2015-03-19 03:17:17 -07:00
parent 37713115be
commit 479b4c0dd3
4 changed files with 54 additions and 0 deletions

View File

@ -547,6 +547,29 @@ class V6000FCPDriverTestCase(test.TestCase):
self.driver.stats['volume_backend_name'])
self.assertEqual(vendor_name, self.driver.stats['vendor_name'])
def test_update_stats_fails_data_query_but_has_cached_stats(self):
"""Stats query to backend fails, but cached stats are available. """
backend_name = self.conf.volume_backend_name
vendor_name = "Violin Memory, Inc."
bn0 = '/cluster/state/master_id'
response1 = {bn0: '1'}
response2 = {}
# fake cached stats, from a previous stats query
self.driver.stats = {'free_capacity_gb': 50, 'total_capacity_gb': 100}
conf = {
'basic.get_node_values.side_effect': [response1, response2],
}
self.driver.common.vip = self.setup_mock_vshare(m_conf=conf)
self.assertIsNone(self.driver._update_stats())
self.assertEqual(100, self.driver.stats['total_capacity_gb'])
self.assertEqual(50, self.driver.stats['free_capacity_gb'])
self.assertEqual(backend_name,
self.driver.stats['volume_backend_name'])
self.assertEqual(vendor_name, self.driver.stats['vendor_name'])
def test_get_active_fc_targets(self):
bn0 = '/vshare/state/global/*'
response0 = {'/vshare/state/global/1': 1,

View File

@ -590,6 +590,29 @@ class V6000ISCSIDriverTestCase(test.TestCase):
self.driver.stats['volume_backend_name'])
self.assertEqual(vendor_name, self.driver.stats['vendor_name'])
def test_update_stats_fails_data_query_but_has_cached_stats(self):
"""Stats query to backend fails, but cached stats are available. """
backend_name = self.conf.volume_backend_name
vendor_name = "Violin Memory, Inc."
bn0 = '/cluster/state/master_id'
response1 = {bn0: '1'}
response2 = {}
# fake cached stats, from a previous stats query
self.driver.stats = {'free_capacity_gb': 50, 'total_capacity_gb': 100}
conf = {
'basic.get_node_values.side_effect': [response1, response2],
}
self.driver.common.vip = self.setup_mock_vshare(m_conf=conf)
self.assertIsNone(self.driver._update_stats())
self.assertEqual(100, self.driver.stats['total_capacity_gb'])
self.assertEqual(50, self.driver.stats['free_capacity_gb'])
self.assertEqual(backend_name,
self.driver.stats['volume_backend_name'])
self.assertEqual(vendor_name, self.driver.stats['vendor_name'])
def testGetShortName_LongName(self):
long_name = "abcdefghijklmnopqrstuvwxyz1234567890"
short_name = "abcdefghijklmnopqrstuvwxyz123456"

View File

@ -440,11 +440,15 @@ class V6000FCDriver(driver.FibreChannelDriver):
total_gb = resp[bn1] / units.Gi
else:
LOG.warn(_LW("Failed to receive update for total_gb stat!"))
if 'total_capacity_gb' in self.stats:
total_gb = self.stats['total_capacity_gb']
if bn2 in resp:
free_gb = resp[bn2] / units.Gi
else:
LOG.warn(_LW("Failed to receive update for free_gb stat!"))
if 'free_capacity_gb' in self.stats:
free_gb = self.stats['free_capacity_gb']
backend_name = self.configuration.volume_backend_name
data['volume_backend_name'] = backend_name or self.__class__.__name__

View File

@ -469,11 +469,15 @@ class V6000ISCSIDriver(driver.ISCSIDriver):
total_gb = resp[bn1] / units.Gi
else:
LOG.warn(_LW("Failed to receive update for total_gb stat!"))
if 'total_capacity_gb' in self.stats:
total_gb = self.stats['total_capacity_gb']
if bn2 in resp:
free_gb = resp[bn2] / units.Gi
else:
LOG.warn(_LW("Failed to receive update for free_gb stat!"))
if 'free_capacity_gb' in self.stats:
free_gb = self.stats['free_capacity_gb']
backend_name = self.configuration.volume_backend_name
data['volume_backend_name'] = backend_name or self.__class__.__name__