Browse Source

[OVN] Fix: Disabling snat after it was enabled

This patch removes a conditional check in the update_router() method
which was verifying if snat was enabled in order to update the nat
rules. This check does not make sense in the update method as if snat
was disabled we should still call update_nat_rules() which will then
remove the NAT entry from the OVN NB DB.

(cherry picked from Neutron ddc8e625f7)

Closes-Bug: #1922089
Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
Change-Id: I8604bc54f727ff9f194575d2dffc041246677c1a
changes/39/792539/1
Lucas Alvares Gomes 3 weeks ago
parent
commit
5ce2b57050
2 changed files with 4 additions and 7 deletions
  1. +4
    -5
      networking_ovn/common/ovn_client.py
  2. +0
    -2
      networking_ovn/tests/unit/l3/test_l3_ovn.py

+ 4
- 5
networking_ovn/common/ovn_client.py View File

@ -1253,11 +1253,10 @@ class OVNClient(object):
else:
# Check if snat has been enabled/disabled and update
new_snat_state = gateway_new.get('enable_snat', True)
if bool(ovn_snats) != new_snat_state:
if utils.is_snat_enabled(new_router) and networks:
self.update_nat_rules(
new_router, networks,
enable_snat=new_snat_state, txn=txn)
if bool(ovn_snats) != new_snat_state and networks:
self.update_nat_rules(
new_router, networks,
enable_snat=new_snat_state, txn=txn)
update = {'external_ids': self._gen_router_ext_ids(new_router)}
update['enabled'] = new_router.get('admin_state_up') or False


+ 0
- 2
networking_ovn/tests/unit/l3/test_l3_ovn.py View File

@ -866,8 +866,6 @@ class OVNL3RouterPlugin(test_mech_driver.OVNMechanismDriverTestCase):
'_check_external_ips_changed')
@mock.patch.object(utils, 'get_lrouter_snats')
@mock.patch.object(utils, 'get_lrouter_ext_gw_static_route')
@mock.patch('networking_ovn.common.utils.is_snat_enabled',
mock.Mock(return_value=True))
@mock.patch('neutron.db.db_base_plugin_v2.NeutronDbPluginV2.get_port')
@mock.patch('networking_ovn.common.ovn_client.OVNClient.'
'_get_router_ports')


Loading…
Cancel
Save