Merge "LBaaS: up state update for members in ERROR state"

This commit is contained in:
Jenkins 2015-08-28 02:18:12 +00:00 committed by Gerrit Code Review
commit b6c4b34bd1
2 changed files with 32 additions and 7 deletions

View File

@ -840,6 +840,13 @@ class EdgeLbDriver(object):
pool_mapping['edge_id'])
pools_stats = lb_stats[1].get('pool', [])
plugin = self._get_lb_plugin()
members = plugin.get_members(
context,
filters={'pool_id': [pool_id]},
fields=['id', 'status'])
member_map = {m['id']: m['status'] for m in members}
for pool_stats in pools_stats:
if pool_stats['poolId'] == pool_mapping['edge_pool_id']:
stats = {'bytes_in': pool_stats.get('bytesIn', 0),
@ -852,10 +859,11 @@ class EdgeLbDriver(object):
member_stats = {}
for member in pool_stats.get('member', []):
member_id = member['name'][len(MEMBER_ID_PFX):]
member_stats[member_id] = {
'status': ('INACTIVE'
if member['status'] == 'DOWN'
else 'ACTIVE')}
if member_map[member_id] != 'ERROR':
member_stats[member_id] = {
'status': ('INACTIVE'
if member['status'] == 'DOWN'
else 'ACTIVE')}
stats['members'] = member_stats
return stats

View File

@ -625,13 +625,22 @@ class TestEdgeLbDriver(base.BaseTestCase):
'rateLimit': 0,
'member': [
{'status': 'UP',
'name': 'Member-1',
'name': 'member-xxx-xxx-xxx-xxx',
'bytesOut': 0,
'memberId': 'member-1',
'totalSessions': 20000,
'ipAddress': '192.168.55.101',
'httpReqRateMax': 0,
'curSessions': 0,
'bytesIn': 0},
{'status': 'UP',
'name': 'member-yyy-yyy-yyy-yyy',
'bytesOut': 0,
'memberId': 'member-2',
'totalSessions': 20000,
'ipAddress': '192.168.55.102',
'httpReqRateMax': 0,
'curSessions': 0,
'bytesIn': 0}],
'poolId': EDGE_POOL_ID,
'maxSessions': 10000,
@ -642,10 +651,18 @@ class TestEdgeLbDriver(base.BaseTestCase):
'bytes_in': 1000000,
'bytes_out': 100000,
'total_connections': 10000,
'members': {'1': {'status': 'ACTIVE'}}}
'members': {'xxx-xxx-xxx-xxx': {'status': 'ACTIVE'}}}
members = [{'id': 'xxx-xxx-xxx-xxx', 'status': 'ACTIVE'},
{'id': 'yyy-yyy-yyy-yyy', 'status': 'ERROR'}]
mock_lb_plugin = mock.Mock()
with mock.patch.object(self.edge_driver.vcns,
'get_loadbalancer_statistics',
return_value=pool_stats):
return_value=pool_stats), \
mock.patch.object(self.edge_driver,
'_get_lb_plugin',
return_value=mock_lb_plugin), \
mock.patch.object(mock_lb_plugin, 'get_members',
return_value=members):
stats = self.edge_driver.stats(self.context, POOL_ID, pool_mapping)
self.assertEqual(stats, expected_stats)