diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py index ab93ea1092f..bb6d65efb2d 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/maintenance.py @@ -398,7 +398,7 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase): def _create_lrouter_port(self, context, port): router_id = port['device_id'] self._ovn_client._l3_plugin.add_router_interface( - context, router_id, {'port_id': port['id']}, may_exist=True) + context, router_id, {'port_id': port['id']}) def _check_subnet_global_dhcp_opts(self): inconsistent_subnets = [] diff --git a/neutron/services/ovn_l3/plugin.py b/neutron/services/ovn_l3/plugin.py index d784f09d17d..dfa39a0b62b 100644 --- a/neutron/services/ovn_l3/plugin.py +++ b/neutron/services/ovn_l3/plugin.py @@ -159,14 +159,12 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase, context, {'router': original_router}) def _add_neutron_router_interface(self, context, router_id, - interface_info, may_exist=False): + interface_info): try: router_interface_info = ( super(OVNL3RouterPlugin, self).add_router_interface( context, router_id, interface_info)) except n_exc.PortInUse: - if not may_exist: - raise # NOTE(lucasagomes): If the port is already being used it means # the interface has been created already, let's just fetch it from # the database. Perhaps the code below should live in Neutron @@ -183,10 +181,9 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase, return router_interface_info - def add_router_interface(self, context, router_id, interface_info, - may_exist=False): + def add_router_interface(self, context, router_id, interface_info=None): router_interface_info = self._add_neutron_router_interface( - context, router_id, interface_info, may_exist=may_exist) + context, router_id, interface_info) try: self._ovn_client.create_router_port( context, router_id, router_interface_info) diff --git a/neutron/tests/unit/extensions/test_l3.py b/neutron/tests/unit/extensions/test_l3.py index fc11cd28029..3c61c9f811b 100644 --- a/neutron/tests/unit/extensions/test_l3.py +++ b/neutron/tests/unit/extensions/test_l3.py @@ -1457,38 +1457,6 @@ class L3NatTestCaseBase(L3NatTestCaseMixin): exc.HTTPBadRequest.code) self.assertFalse(plugin.get_ports(context.get_admin_context())) - def test_router_add_interface_dup_port(self): - '''This tests that if multiple routers add one port as their - interfaces. Only the first router's interface would be added - to this port. All the later requests would return exceptions. - ''' - with self.router() as r1, self.router() as r2, self.network() as n: - with self.subnet(network=n) as s: - with self.port(subnet=s) as p: - self._router_interface_action('add', - r1['router']['id'], - None, - p['port']['id']) - # mock out the sequential check - plugin = 'neutron.db.l3_db.L3_NAT_dbonly_mixin' - check_p = mock.patch(plugin + '._check_router_port', - port_id=p['port']['id'], - device_id=r2['router']['id'], - return_value=p['port']) - checkport = check_p.start() - # do regular checkport after first skip - checkport.side_effect = check_p.stop() - self._router_interface_action('add', - r2['router']['id'], - None, - p['port']['id'], - exc.HTTPConflict.code) - # clean-up - self._router_interface_action('remove', - r1['router']['id'], - None, - p['port']['id']) - def _assert_body_port_id_and_update_port(self, body, mock_update_port, port_id, device_id): self.assertNotIn('port_id', body) diff --git a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py index ccf2eab53b5..075946648f8 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py +++ b/neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/ovsdb/test_maintenance.py @@ -276,8 +276,7 @@ class TestDBInconsistenciesPeriodics(testlib_api.SqlTestCaseLight, self.periodic._create_lrouter_port(self.ctx, port) l3_mock = self.periodic._ovn_client._l3_plugin l3_mock.add_router_interface.assert_called_once_with( - self.ctx, port['device_id'], {'port_id': port['id']}, - may_exist=True) + self.ctx, port['device_id'], {'port_id': port['id']}) @mock.patch.object(maintenance.LOG, 'debug') def test__log_maintenance_inconsistencies(self, mock_log):