Skip to content

Commit 4ea86ce

Browse files
Ensure LB with HM rechecks member status after re-enable
This patch fixes an issue where disabling a LoadBalancer member sets its status to ERROR instead of OFFLINE. While in the ERROR state, re-enabling the member does not update its status, and the member is not reintegrated into the "vips" field of the LoadBalancer row in the OVN NB database. As a result, the Health Monitor does not resume its checks on the member. This patch ensures that re-enabled members are correctly reintegrated and that health checks are properly resumed. Closes-bug: #2112110 Change-Id: If2ca76df87c0f5a713604212ed6cb77792d0010c
1 parent 84d6dfc commit 4ea86ce

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

ovn_octavia_provider/helper.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,8 +2795,14 @@ def member_update(self, member):
27952795
# if HM exists trust on neutron:member_status
27962796
# as the last status valid for the member
27972797
if ovn_lb.health_check:
2798-
# search status of member_uuid
2799-
member_operating_status = last_status
2798+
# Put member ONLINE if was OFFLINE and trust on HM to
2799+
# come back to ERROR in case neccesary, it was already
2800+
# on ERROR keeps at that way.
2801+
member_operating_status = (
2802+
constants.ERROR
2803+
if last_status == constants.ERROR
2804+
else constants.ONLINE
2805+
)
28002806
else:
28012807
member_operating_status = constants.NO_MONITOR
28022808
else:
@@ -2815,12 +2821,18 @@ def member_update(self, member):
28152821
) or (
28162822
last_status == constants.OFFLINE and
28172823
member_operating_status != constants.OFFLINE
2824+
) or (
2825+
member[constants.ADMIN_STATE_UP]
28182826
):
28192827
commands = []
28202828
commands.extend(self._refresh_lb_vips(ovn_lb,
28212829
ovn_lb.external_ids))
28222830
self._execute_commands(commands)
2823-
2831+
if ovn_lb.health_check:
2832+
delete = not member[constants.ADMIN_STATE_UP]
2833+
self._update_hm_member(
2834+
ovn_lb, pool_key, member.get(constants.ADDRESS),
2835+
delete=delete)
28242836
except Exception:
28252837
LOG.exception(ovn_const.EXCEPTION_MSG, "update of member")
28262838
error_updating_member = True
@@ -3983,9 +3995,8 @@ def sm_update_event_handler(self, row, sm_delete_event=False):
39833995
"ovn_lbs": ovn_lbs,
39843996
"ip": row.ip,
39853997
"port": str(row.port),
3986-
"status": row.status
3987-
if not sm_delete_event
3988-
else ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE,
3998+
"status": row.status,
3999+
"delete": sm_delete_event,
39894000
}
39904001
self.add_request({'type': ovn_const.REQ_TYPE_HM_UPDATE_EVENT,
39914002
'info': request_info})
@@ -4130,9 +4141,12 @@ def hm_update_event(self, info):
41304141
if not member_id:
41314142
LOG.warning('Member for event not found, info: %s', info)
41324143
else:
4133-
member_status = constants.ONLINE
4134-
if info['status'] == ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE:
4144+
if info['delete']:
4145+
member_status = constants.OFFLINE
4146+
elif info['status'] == ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE:
41354147
member_status = constants.ERROR
4148+
else:
4149+
member_status = constants.ONLINE
41364150

41374151
self._update_external_ids_member_status(ovn_lb, member_id,
41384152
member_status)

ovn_octavia_provider/tests/functional/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,9 @@ def _update_member_and_validate(self, lb_data, pool_id, member_address,
991991
'provisioning_status': 'ACTIVE',
992992
'operating_status': o_constants.ONLINE}],
993993
'members': [{"id": member.member_id,
994-
'provisioning_status': 'ACTIVE'}],
994+
'provisioning_status': 'ACTIVE',
995+
'operating_status': o_constants.ONLINE
996+
if admin_state_up else o_constants.OFFLINE}],
995997
'loadbalancers': [{'id': pool.loadbalancer_id,
996998
'provisioning_status': 'ACTIVE',
997999
'operating_status': o_constants.ONLINE}],

ovn_octavia_provider/tests/unit/test_helper.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6051,6 +6051,7 @@ def test_hm_update_event_offline(self):
60516051
'logical_port': 'a-logical-port',
60526052
'src_ip': src_ip,
60536053
'port': self.member_port,
6054+
'delete': False,
60546055
'protocol': self.ovn_hm_lb.protocol,
60556056
'status': ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE})
60566057
self.hm_update_event.run('update', row, mock.ANY)
@@ -6059,6 +6060,7 @@ def test_hm_update_event_offline(self):
60596060
{'ovn_lbs': [self.ovn_hm_lb],
60606061
'ip': self.member_address,
60616062
'port': self.member_port,
6063+
'delete': False,
60626064
'status': ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE},
60636065
'type': 'hm_update_event'}
60646066
self.mock_add_request.assert_called_once_with(expected)
@@ -6087,7 +6089,8 @@ def test_hm_update_event_offline_by_delete(self):
60876089
{'ovn_lbs': [self.ovn_hm_lb],
60886090
'ip': self.member_address,
60896091
'port': self.member_port,
6090-
'status': ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE},
6092+
'delete': True,
6093+
'status': ovn_const.HM_EVENT_MEMBER_PORT_ONLINE},
60916094
'type': 'hm_update_event'}
60926095
self.mock_add_request.assert_called_once_with(expected)
60936096
self.helper.ovn_nbdb_api.db_find_rows.assert_called_once_with(
@@ -6169,13 +6172,14 @@ def test_hm_update_event_member_port_not_found(self):
61696172
self._test_hm_update_no_member(False, True)
61706173

61716174
def _test_hm_update_status(self, ovn_lbs, member_id, ip, port,
6172-
mb_status):
6175+
mb_status, delete=False):
61736176
info = {
61746177
'ovn_lbs': ovn_lbs,
61756178
'ip': ip,
61766179
'logical_port': 'a-logical-port',
61776180
'src_ip': '10.22.33.4',
61786181
'port': port,
6182+
'delete': delete,
61796183
'protocol': ovn_lbs[0].protocol,
61806184
'status': [mb_status]}
61816185
mb_status_ovn = 'error' if mb_status == 'offline' else mb_status
@@ -6472,6 +6476,7 @@ def test_hm_update_status_offline_two_lbs_affected(self):
64726476
'logical_port': 'a-logical-port',
64736477
'src_ip': '10.22.33.4',
64746478
'port': '8080',
6479+
'delete': False,
64756480
'protocol': self.ovn_hm_lb.protocol,
64766481
'status': ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE}
64776482
self._update_external_ids_member_status(self.ovn_hm_lb, member['id'],
@@ -6596,6 +6601,7 @@ def test_hm_update_status_offline_two_members_diff_lbs_port(self):
65966601
'logical_port': 'a-logical-port',
65976602
'src_ip': '10.22.33.4',
65986603
'port': '8081',
6604+
'delete': False,
65996605
'protocol': ovn_hm_lb2.protocol,
66006606
'status': ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE}
66016607

0 commit comments

Comments
 (0)