From 8c6f7745041dca8eb4568c255e2033bf54ee9fe5 Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Wed, 28 Apr 2021 13:41:15 +0100 Subject: [PATCH] [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. Change-Id: Ice20d22365acaf33ee211b1e38b7d0bc151c1ba8 Closes-Bug: #1922089 Signed-off-by: Lucas Alvares Gomes (cherry picked from commit ddc8e625f714aebd65a454f23fedc6d9a9320e89) --- .../ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py | 9 ++++----- neutron/tests/unit/services/ovn_l3/test_plugin.py | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py index 8d7c0f0ec6d..e26b4bf9c5c 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py @@ -1224,11 +1224,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 diff --git a/neutron/tests/unit/services/ovn_l3/test_plugin.py b/neutron/tests/unit/services/ovn_l3/test_plugin.py index ef6ddf59c55..e7672517aa5 100644 --- a/neutron/tests/unit/services/ovn_l3/test_plugin.py +++ b/neutron/tests/unit/services/ovn_l3/test_plugin.py @@ -891,8 +891,6 @@ class TestOVNL3RouterPlugin(test_mech_driver.Ml2PluginV2TestCase): 'ovn_client.OVNClient._check_external_ips_changed') @mock.patch.object(utils, 'get_lrouter_snats') @mock.patch.object(utils, 'get_lrouter_ext_gw_static_route') - @mock.patch('neutron.common.ovn.utils.is_snat_enabled', - mock.Mock(return_value=True)) @mock.patch('neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb.' 'ovn_client.OVNClient._get_router_ports') @mock.patch('neutron.db.extraroute_db.ExtraRoute_dbonly_mixin.'