Merge "Ensure LB with HM rechecks member status after re-enable"

This commit is contained in:
Zuul
2025-09-17 10:11:22 +00:00
committed by Gerrit Code Review
3 changed files with 33 additions and 11 deletions

View File

@@ -2795,8 +2795,14 @@ class OvnProviderHelper():
# if HM exists trust on neutron:member_status
# as the last status valid for the member
if ovn_lb.health_check:
# search status of member_uuid
member_operating_status = last_status
# Put member ONLINE if was OFFLINE and trust on HM to
# come back to ERROR in case neccesary, it was already
# on ERROR keeps at that way.
member_operating_status = (
constants.ERROR
if last_status == constants.ERROR
else constants.ONLINE
)
else:
member_operating_status = constants.NO_MONITOR
else:
@@ -2815,12 +2821,18 @@ class OvnProviderHelper():
) or (
last_status == constants.OFFLINE and
member_operating_status != constants.OFFLINE
) or (
member[constants.ADMIN_STATE_UP]
):
commands = []
commands.extend(self._refresh_lb_vips(ovn_lb,
ovn_lb.external_ids))
self._execute_commands(commands)
if ovn_lb.health_check:
delete = not member[constants.ADMIN_STATE_UP]
self._update_hm_member(
ovn_lb, pool_key, member.get(constants.ADDRESS),
delete=delete)
except Exception:
LOG.exception(ovn_const.EXCEPTION_MSG, "update of member")
error_updating_member = True
@@ -4021,9 +4033,8 @@ class OvnProviderHelper():
"ovn_lbs": ovn_lbs,
"ip": row.ip,
"port": str(row.port),
"status": row.status
if not sm_delete_event
else ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE,
"status": row.status,
"delete": sm_delete_event,
}
self.add_request({'type': ovn_const.REQ_TYPE_HM_UPDATE_EVENT,
'info': request_info})
@@ -4168,9 +4179,12 @@ class OvnProviderHelper():
if not member_id:
LOG.warning('Member for event not found, info: %s', info)
else:
member_status = constants.ONLINE
if info['status'] == ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE:
if info['delete']:
member_status = constants.OFFLINE
elif info['status'] == ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE:
member_status = constants.ERROR
else:
member_status = constants.ONLINE
self._update_external_ids_member_status(ovn_lb, member_id,
member_status)

View File

@@ -991,7 +991,9 @@ class TestOvnOctaviaBase(base.TestOVNFunctionalBase,
'provisioning_status': 'ACTIVE',
'operating_status': o_constants.ONLINE}],
'members': [{"id": member.member_id,
'provisioning_status': 'ACTIVE'}],
'provisioning_status': 'ACTIVE',
'operating_status': o_constants.ONLINE
if admin_state_up else o_constants.OFFLINE}],
'loadbalancers': [{'id': pool.loadbalancer_id,
'provisioning_status': 'ACTIVE',
'operating_status': o_constants.ONLINE}],

View File

@@ -6074,6 +6074,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
'logical_port': 'a-logical-port',
'src_ip': src_ip,
'port': self.member_port,
'delete': False,
'protocol': self.ovn_hm_lb.protocol,
'status': ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE})
self.hm_update_event.run('update', row, mock.ANY)
@@ -6082,6 +6083,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
{'ovn_lbs': [self.ovn_hm_lb],
'ip': self.member_address,
'port': self.member_port,
'delete': False,
'status': ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE},
'type': 'hm_update_event'}
self.mock_add_request.assert_called_once_with(expected)
@@ -6110,7 +6112,8 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
{'ovn_lbs': [self.ovn_hm_lb],
'ip': self.member_address,
'port': self.member_port,
'status': ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE},
'delete': True,
'status': ovn_const.HM_EVENT_MEMBER_PORT_ONLINE},
'type': 'hm_update_event'}
self.mock_add_request.assert_called_once_with(expected)
self.helper.ovn_nbdb_api.db_find_rows.assert_called_once_with(
@@ -6192,13 +6195,14 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
self._test_hm_update_no_member(False, True)
def _test_hm_update_status(self, ovn_lbs, member_id, ip, port,
mb_status):
mb_status, delete=False):
info = {
'ovn_lbs': ovn_lbs,
'ip': ip,
'logical_port': 'a-logical-port',
'src_ip': '10.22.33.4',
'port': port,
'delete': delete,
'protocol': ovn_lbs[0].protocol,
'status': [mb_status]}
mb_status_ovn = 'error' if mb_status == 'offline' else mb_status
@@ -6495,6 +6499,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
'logical_port': 'a-logical-port',
'src_ip': '10.22.33.4',
'port': '8080',
'delete': False,
'protocol': self.ovn_hm_lb.protocol,
'status': ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE}
self._update_external_ids_member_status(self.ovn_hm_lb, member['id'],
@@ -6619,6 +6624,7 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
'logical_port': 'a-logical-port',
'src_ip': '10.22.33.4',
'port': '8081',
'delete': False,
'protocol': ovn_hm_lb2.protocol,
'status': ovn_const.HM_EVENT_MEMBER_PORT_OFFLINE}