Browse Source

Correctly set member operating status

According to the Octavia API, a provider driver should
set the member operating_status field to OFFLINE on a
create if admin_state_up=False in the call. The OVN
provider wasn't looking at that flag, so always had
operating_status set to NO_MONITOR (the default when
health monitors are not supported).

Also, when a member is updated from admin_state_up=False
to True, operating_status must show NO_MONITOR since no
health monitor is configured and the status is unknown.

Change-Id: Idca5e682894b237649a24ceb5092605102f9bfff
Closes-bug: #1906568
(cherry picked from commit 2399b69bf1)
changes/05/783205/1 0.4.0
Brian Haley 8 months ago
committed by Brian Haley
parent
commit
19e7ad6544
  1. 3
      ovn_octavia_provider/driver.py
  2. 23
      ovn_octavia_provider/helper.py
  3. 1
      ovn_octavia_provider/tests/unit/test_driver.py
  4. 16
      ovn_octavia_provider/tests/unit/test_helper.py

3
ovn_octavia_provider/driver.py

@ -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,

23
ovn_octavia_provider/helper.py

@ -1483,11 +1483,13 @@ class OvnProviderHelper(object):
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}]}
@ -1625,8 +1627,19 @@ class OvnProviderHelper(object):
self._update_member(member, ovn_lb, pool_key)
if constants.ADMIN_STATE_UP in member:
if member[constants.ADMIN_STATE_UP]:
member_status[constants.OPERATING_STATUS] = (
constants.ONLINE)
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)

1
ovn_octavia_provider/tests/unit/test_driver.py

@ -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}

16
ovn_octavia_provider/tests/unit/test_helper.py

@ -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,
@ -1133,6 +1134,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):
@ -1238,6 +1241,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 = [

Loading…
Cancel
Save