Skip to content

Commit ced8c0d

Browse files
Dmitriy Rabotyagovfernandoroyosanchez
authored andcommitted
Fix LB disable/enable functionality
At the moment disabling/enabling Load Balancer created with the OVN provider will act in reverse. This is due to reffering to actual state of the Load Balancer rather then intended state while fetching list of VIPs that should be defined in OVN. A mistake was made when ovn_lb.external_ids was attempted to be updated as object is protected and update simply do not pass. Thus, we create a copy of it and pass to the _refresh_lb_vips instead. Closes-Bug: #2086194 Change-Id: I6271079879d6bb724092a4693c7663034f4e2b9d
1 parent 84d6dfc commit ced8c0d

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

ovn_octavia_provider/helper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,14 +1904,14 @@ def lb_update(self, loadbalancer):
19041904
if str(ovn_lb.external_ids['enabled']) != str(lb_enabled):
19051905
commands = []
19061906
enable_info = {'enabled': str(lb_enabled)}
1907-
ovn_lb.external_ids['enabled'] = str(lb_enabled)
1907+
ovn_lb_external_ids = ovn_lb.external_ids
1908+
ovn_lb_external_ids.update(enable_info)
19081909
commands.append(
19091910
self.ovn_nbdb_api.db_set('Load_Balancer', ovn_lb.uuid,
19101911
('external_ids', enable_info))
19111912
)
19121913
commands.extend(
1913-
self._refresh_lb_vips(ovn_lb,
1914-
ovn_lb.external_ids))
1914+
self._refresh_lb_vips(ovn_lb, ovn_lb_external_ids))
19151915
self._execute_commands(commands)
19161916
if lb_enabled:
19171917
operating_status = constants.ONLINE

ovn_octavia_provider/tests/unit/test_helper.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,29 +1506,27 @@ def test_lb_update_disabled(self, refresh_vips):
15061506
@mock.patch.object(ovn_helper.OvnProviderHelper, '_refresh_lb_vips')
15071507
def test_lb_update_enabled(self, refresh_vips):
15081508
# Change the mock, its enabled by default.
1509-
self.ovn_lb.external_ids.update({'enabled': False})
1510-
self.lb['admin_state_up'] = True
1509+
self.lb[constants.ADMIN_STATE_UP] = False
15111510
status = self.helper.lb_update(self.lb)
15121511
self.assertEqual(status['loadbalancers'][0]['provisioning_status'],
15131512
constants.ACTIVE)
15141513
self.assertEqual(status['loadbalancers'][0]['operating_status'],
1515-
constants.ONLINE)
1514+
constants.OFFLINE)
15161515
refresh_vips.assert_called_once_with(
15171516
self.ovn_lb, self.ovn_lb.external_ids)
15181517
self.helper.ovn_nbdb_api.db_set.assert_called_once_with(
15191518
'Load_Balancer', self.ovn_lb.uuid,
1520-
('external_ids', {'enabled': 'True'}))
1519+
('external_ids', {'enabled': 'False'}))
15211520
# update to re-enable
1522-
self.ovn_lb.external_ids.update({'enabled': True})
1523-
self.lb['admin_state_up'] = True
1521+
self.lb[constants.ADMIN_STATE_UP] = True
15241522
status = self.helper.lb_update(self.lb)
15251523
self.assertEqual(status['loadbalancers'][0]['provisioning_status'],
15261524
constants.ACTIVE)
15271525
self.assertEqual(status['loadbalancers'][0]['operating_status'],
15281526
constants.ONLINE)
1529-
refresh_vips.assert_called_once_with(
1527+
refresh_vips.assert_called_with(
15301528
self.ovn_lb, self.ovn_lb.external_ids)
1531-
self.helper.ovn_nbdb_api.db_set.assert_called_once_with(
1529+
self.helper.ovn_nbdb_api.db_set.assert_called_with(
15321530
'Load_Balancer', self.ovn_lb.uuid,
15331531
('external_ids', {'enabled': 'True'}))
15341532

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Enabling and disabling Load Balancers with the OVN provider now works
5+
properly, assigning or removing VIP definitions in the OVN Northbound
6+
database according to the issued command.

0 commit comments

Comments
 (0)