Browse Source

Check if no members in pool better in batch update

member_batch_update() might find a loadbalancer with
a pool that contains no members, but calling split(',')
will result in an existing member list of ['']. Force
it to an empty list if there are no members.

Closes-Bug: #1912779
Change-Id: Iec46c3e1ebef822d43964e13962153dc8760ee42
(cherry picked from commit 6e30b8552c)
changes/12/779612/1
Michał Nasiadka 3 months ago
committed by Michal Nasiadka
parent
commit
d96296752d
2 changed files with 12 additions and 1 deletions
  1. +2
    -1
      ovn_octavia_provider/driver.py
  2. +10
    -0
      ovn_octavia_provider/tests/unit/test_driver.py

+ 2
- 1
ovn_octavia_provider/driver.py View File

@ -292,7 +292,8 @@ class OvnProviderDriver(driver_base.ProviderDriver):
skipped_members = []
pool_key, ovn_lb = self._ovn_helper._find_ovn_lb_by_pool_id(pool_id)
external_ids = copy.deepcopy(ovn_lb.external_ids)
existing_members = external_ids[pool_key].split(',')
pool = external_ids[pool_key]
existing_members = pool.split(',') if pool else []
members_to_delete = copy.copy(existing_members)
for member in members:
if (self._check_monitor_options(member) or


+ 10
- 0
ovn_octavia_provider/tests/unit/test_driver.py View File

@ -11,6 +11,7 @@
# License for the specific language governing permissions and limitations
# under the License.
#
import copy
from unittest import mock
from octavia_lib.api.drivers import data_models
@ -289,6 +290,15 @@ class TestOvnProviderDriver(ovn_base.TestOvnOctaviaBase):
[self.ref_member, self.update_member])
self.assertEqual(self.mock_add_request.call_count, 3)
def test_member_batch_update_no_members(self):
pool_key = 'pool_%s' % self.pool_id
ovn_lb = copy.copy(self.ovn_lb)
ovn_lb.external_ids[pool_key] = []
self.mock_find_lb_pool_key.return_value = ovn_lb
self.driver.member_batch_update(self.pool_id,
[self.ref_member, self.update_member])
self.assertEqual(self.mock_add_request.call_count, 2)
def test_member_batch_update_skipped_monitor(self):
self.ref_member.monitor_address = '10.11.1.1'
self.assertRaises(exceptions.UnsupportedOptionError,


Loading…
Cancel
Save