Merge "Correctly set member operating status"

This commit is contained in:
Zuul 2021-03-12 01:31:20 +00:00 committed by Gerrit Code Review
commit 3fd3c54226
4 changed files with 36 additions and 7 deletions

View File

@ -280,7 +280,8 @@ class OvnProviderDriver(driver_base.ProviderDriver):
'address': old_member.address,
'protocol_port': old_member.protocol_port,
'pool_id': old_member.pool_id,
'subnet_id': old_member.subnet_id}
'subnet_id': old_member.subnet_id,
'old_admin_state_up': old_member.admin_state_up}
if not isinstance(new_member.admin_state_up, o_datamodels.UnsetType):
request_info['admin_state_up'] = new_member.admin_state_up
request = {'type': ovn_const.REQ_TYPE_MEMBER_UPDATE,

View File

@ -1472,11 +1472,13 @@ class OvnProviderHelper():
pool = {constants.ID: member[constants.POOL_ID],
constants.PROVISIONING_STATUS: constants.ACTIVE,
constants.OPERATING_STATUS: constants.ONLINE}
member_status = {constants.ID: member[constants.ID],
constants.PROVISIONING_STATUS: constants.ACTIVE}
if not member[constants.ADMIN_STATE_UP]:
member_status[constants.OPERATING_STATUS] = constants.OFFLINE
status = {
constants.POOLS: [pool],
constants.MEMBERS: [
{constants.ID: member[constants.ID],
constants.PROVISIONING_STATUS: constants.ACTIVE}],
constants.MEMBERS: [member_status],
constants.LOADBALANCERS: [
{constants.ID: ovn_lb.name,
constants.PROVISIONING_STATUS: constants.ACTIVE}]}
@ -1614,8 +1616,19 @@ class OvnProviderHelper():
self._update_member(member, ovn_lb, pool_key)
if constants.ADMIN_STATE_UP in member:
if member[constants.ADMIN_STATE_UP]:
old_admin_state_up = member.get('old_admin_state_up')
if old_admin_state_up is None:
exist_member = self._octavia_driver_lib.get_member(
member[constants.ID])
if exist_member:
old_admin_state_up = exist_member.admin_state_up
if old_admin_state_up:
member_status[constants.OPERATING_STATUS] = (
constants.ONLINE)
else:
# going from down to up should reflect NO_MONITOR state
member_status[constants.OPERATING_STATUS] = (
constants.NO_MONITOR)
else:
member_status[constants.OPERATING_STATUS] = (
constants.OFFLINE)

View File

@ -273,6 +273,7 @@ class TestOvnProviderDriver(ovn_base.TestOvnOctaviaBase):
'protocol_port': self.ref_member.protocol_port,
'pool_id': self.ref_member.pool_id,
'admin_state_up': self.update_member.admin_state_up,
'old_admin_state_up': self.ref_member.admin_state_up,
'subnet_id': self.ref_member.subnet_id}
expected_dict = {'type': ovn_const.REQ_TYPE_MEMBER_UPDATE,
'info': info}

View File

@ -62,7 +62,8 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
'protocol_port': self.member_port,
'subnet_id': self.member_subnet_id,
'pool_id': self.member_pool_id,
'admin_state_up': True}
'admin_state_up': True,
'old_admin_state_up': True}
self.ovn_nbdb_api = mock.patch.object(self.helper, 'ovn_nbdb_api')
self.ovn_nbdb_api.start()
add_req_thread = mock.patch.object(ovn_helper.OvnProviderHelper,
@ -1128,6 +1129,8 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
constants.ACTIVE)
self.assertEqual(status['members'][0]['provisioning_status'],
constants.ACTIVE)
self.assertEqual(status['members'][0]['operating_status'],
constants.OFFLINE)
@mock.patch.object(ovn_helper.OvnProviderHelper, '_add_member')
def test_member_create_exception(self, mock_add_member):
@ -1233,6 +1236,17 @@ class TestOvnProviderHelper(ovn_base.TestOvnOctaviaBase):
constants.ACTIVE)
self.assertEqual(status['members'][0]['operating_status'],
constants.OFFLINE)
self.member['old_admin_state_up'] = False
self.member['admin_state_up'] = True
status = self.helper.member_update(self.member)
self.assertEqual(status['loadbalancers'][0]['provisioning_status'],
constants.ACTIVE)
self.assertEqual(status['pools'][0]['provisioning_status'],
constants.ACTIVE)
self.assertEqual(status['members'][0]['provisioning_status'],
constants.ACTIVE)
self.assertEqual(status['members'][0]['operating_status'],
constants.NO_MONITOR)
def test_member_update_disabled_lb(self):
self.helper._find_ovn_lb_with_pool_key.side_effect = [