Browse Source

Merge "Don't send malformed status update to Octavia" into stable/train

tags/7.1.0
Zuul Gerrit Code Review 1 month ago
parent
commit
743d853b98
2 changed files with 32 additions and 0 deletions
  1. +11
    -0
      networking_ovn/octavia/ovn_driver.py
  2. +21
    -0
      networking_ovn/tests/unit/octavia/test_ovn_driver.py

+ 11
- 0
networking_ovn/octavia/ovn_driver.py View File

@@ -14,6 +14,7 @@

import atexit
import copy
import re
import threading

import netaddr
@@ -241,6 +242,14 @@ class OvnProviderHelper(object):
return not any([k.startswith('listener') or k.startswith('pool')
for k in external_ids])

@staticmethod
def _delete_disabled_from_status(status):
d_regex = ':%s$' % DISABLED_RESOURCE_SUFFIX
return {
k: [{c: re.sub(d_regex, '', d) for c, d in i.items()}
for i in v]
for k, v in status.items()}

def _check_and_set_ssl_files(self):
# TODO(reedip): Make ovsdb_monitor's _check_and_set_ssl_files() public
# This is a copy of ovsdb_monitor._check_and_set_ssl_files
@@ -471,6 +480,8 @@ class OvnProviderHelper(object):

def _update_status_to_octavia(self, status):
try:
status = OvnProviderHelper._delete_disabled_from_status(status)
LOG.debug('Updating status to octavia: %s', status)
self._octavia_driver_lib.update_loadbalancer_status(status)
except driver_exceptions.UpdateStatusError as e:
msg = ("Error while updating the load balancer "


+ 21
- 0
networking_ovn/tests/unit/octavia/test_ovn_driver.py View File

@@ -764,6 +764,27 @@ class TestOvnProviderHelper(TestOvnOctaviaBase):
self.ovn_lb.external_ids.pop('pool_%s' % self.pool_id)
self.assertTrue(f(self.ovn_lb.external_ids))

def test__delete_disabled_from_status(self):
f = self.helper._delete_disabled_from_status
status = {
'pools': [
{'id': 'f:D', 'provisioning_status': 'ACTIVE',
'operating_status': 'ONLINE'}],
'members': [
{'id': 'foo:D',
'provisioning_status': 'ACTIVE'}]}
expected = {
'pools': [
{'id': 'f', 'provisioning_status': 'ACTIVE',
'operating_status': 'ONLINE'}],
'members': [
{'id': 'foo',
'provisioning_status': 'ACTIVE'}]}
self.assertEqual(f(status), expected)
self.assertEqual(f(expected), expected)
status = {}
self.assertEqual(f(status), {})

def test__find_ovn_lbs(self):
self.mock_find_ovn_lbs.stop()
f = self.helper._find_ovn_lbs


Loading…
Cancel
Save