Fix healthmonitor message v2 for UDP listeners

Multi-listener LB commit (Idaccbcfa0126f1e26fbb3ad770c65c9266cfad5b)
introduced a v2 message for octavia healthmonitor.

This commit fixes an issue with healthmonitor messages for UDP
listeners, they didn't follow the v2 message specification: pools
dictionaries were stored in listener objects (v1 format) instead of
being stored as in the root dictionary of the message.

Story: 2005736
Task: 33394

Change-Id: I93e5eb5bc69fe4de4c450c09367b319769ef07db
(cherry picked from commit cad80a6c7d)
This commit is contained in:
Gregory Thiemonge 2019-09-16 14:57:25 +02:00
parent 6d49c69928
commit 5ecfa0a555
2 changed files with 15 additions and 15 deletions

View File

@ -189,11 +189,11 @@ def build_stats_message():
'totconns': listener_stats['stats']['stot'],
'ereq': listener_stats['stats']['ereq']
}
udp_listener_dict['pools'] = {}
if pool_status:
udp_listener_dict['pools'] = {
pool_status['lvs']['uuid']: {
"status": pool_status['lvs']['status'],
"members": pool_status['lvs']['members']}}
pool_id = pool_status['lvs']['uuid']
msg['pools'][pool_id] = {
"status": pool_status['lvs']['status'],
"members": pool_status['lvs']['members']
}
msg['listeners'][listener_id] = udp_listener_dict
return msg

View File

@ -333,7 +333,7 @@ class TestHealthDaemon(base.TestCase):
"get_udp_listeners_stats")
@mock.patch("octavia.amphorae.backends.agent.api_server.util."
"get_udp_listeners")
def test_bulid_stats_message_with_udp_listener(
def test_build_stats_message_with_udp_listener(
self, mock_get_udp_listeners, mock_get_listener_stats,
mock_get_pool_status):
udp_listener_id1 = uuidutils.generate_uuid()
@ -371,20 +371,20 @@ class TestHealthDaemon(base.TestCase):
'listeners': {
udp_listener_id1: {
'status': constants.OPEN,
'pools': {
pool_id: {
'status': constants.UP,
'members': {
member_id1: constants.UP,
member_id2: constants.UP}}},
'stats': {'conns': 0, 'totconns': 5, 'ereq': 0,
'rx': 6387472, 'tx': 7490}},
udp_listener_id3: {
'status': constants.DOWN,
'pools': {},
'stats': {'conns': 0, 'totconns': 0, 'ereq': 0,
'rx': 0, 'tx': 0}}}, 'pools': {}, 'id': None,
'seq': mock.ANY, 'ver': health_daemon.MSG_VER}
'rx': 0, 'tx': 0}}},
'pools': {
pool_id: {
'status': constants.UP,
'members': {
member_id1: constants.UP,
member_id2: constants.UP}}},
'id': None,
'seq': mock.ANY, 'ver': health_daemon.MSG_VER}
msg = health_daemon.build_stats_message()
self.assertEqual(expected, msg)