Browse Source

Use OVN mech driver OVSDB connections for l3 plugin

It is possible to re-use the mech driver ovsdb connections in the
ovn l3 plugin, saving the overhead of two db connections/in-memory
copies of the db per process.

Closes-Bug: #1864548
(cherry picked from Neutron I022dea485f42cf76c4cec67ee43eed9a3770ec9c)

Change-Id: I5fdd80f91ccb23edf6430045d812043e7d3df382
(cherry picked from commit 632dee5d66)
changes/12/723712/1
Terry Wilson 1 year ago
parent
commit
85ec5168ad
  1. 22
      networking_ovn/l3/l3_ovn.py
  2. 10
      networking_ovn/ml2/mech_driver.py
  3. 13
      networking_ovn/tests/functional/base.py

22
networking_ovn/l3/l3_ovn.py

@ -40,7 +40,6 @@ from networking_ovn.common import ovn_client
from networking_ovn.common import utils
from networking_ovn.db import revision as db_rev
from networking_ovn.l3 import l3_ovn_scheduler
from networking_ovn.ovsdb import impl_idl_ovn
LOG = log.getLogger(__name__)
@ -66,9 +65,8 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
def __init__(self):
LOG.info("Starting OVNL3RouterPlugin")
super(OVNL3RouterPlugin, self).__init__()
self._nb_ovn_idl = None
self._sb_ovn_idl = None
self._plugin_property = None
self._mech = None
self._ovn_client_inst = None
self.scheduler = l3_ovn_scheduler.get_scheduler()
self._register_precommit_callbacks()
@ -90,19 +88,11 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
@property
def _ovn(self):
if self._nb_ovn_idl is None:
LOG.info("Getting OvsdbNbOvnIdl")
conn = impl_idl_ovn.get_connection(impl_idl_ovn.OvsdbNbOvnIdl)
self._nb_ovn_idl = impl_idl_ovn.OvsdbNbOvnIdl(conn)
return self._nb_ovn_idl
return self._plugin_driver.nb_ovn
@property
def _sb_ovn(self):
if self._sb_ovn_idl is None:
LOG.info("Getting OvsdbSbOvnIdl")
conn = impl_idl_ovn.get_connection(impl_idl_ovn.OvsdbSbOvnIdl)
self._sb_ovn_idl = impl_idl_ovn.OvsdbSbOvnIdl(conn)
return self._sb_ovn_idl
return self._plugin_driver.sb_ovn
@property
def _plugin(self):
@ -110,6 +100,12 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
self._plugin_property = directory.get_plugin()
return self._plugin_property
@property
def _plugin_driver(self):
if self._mech is None:
self._mech = self._plugin.mechanism_manager.mech_drivers['ovn'].obj
return self._mech
def get_plugin_type(self):
return plugin_constants.L3

10
networking_ovn/ml2/mech_driver.py

@ -123,6 +123,16 @@ class OVNMechanismDriver(api.MechanismDriver):
self._sb_ovn)
return self._ovn_client_inst
@property
def nb_ovn(self):
# NOTE (twilson): This and sb_ovn can be moved to instance variables
# once all references to the private versions are changed
return self._nb_ovn
@property
def sb_ovn(self):
return self._sb_ovn
def _setup_vif_port_bindings(self):
self.supported_vnic_types = [portbindings.VNIC_NORMAL,
portbindings.VNIC_DIRECT]

13
networking_ovn/tests/functional/base.py

@ -214,23 +214,10 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase):
def restart(self):
self.stop()
# The OVN sync test starts its own synchronizers...
self.l3_plugin._nb_ovn_idl.ovsdb_connection.stop()
self.l3_plugin._sb_ovn_idl.ovsdb_connection.stop()
# Stop our monitor connections
self.nb_api.ovsdb_connection.stop()
self.sb_api.ovsdb_connection.stop()
if self.ovsdb_server_mgr:
self.ovsdb_server_mgr.stop()
self.mech_driver._nb_ovn = None
self.mech_driver._sb_ovn = None
self.l3_plugin._nb_ovn_idl = None
self.l3_plugin._sb_ovn_idl = None
self.nb_api.ovsdb_connection = None
self.sb_api.ovsdb_connection = None
self._start_ovsdb_server_and_idls()
def add_fake_chassis(self, host, physical_nets=None, external_ids=None):

Loading…
Cancel
Save