[OVN] Reduce the number of watched tables in MetadataProxyHandler

This patch changes the SB IDL from the MetadataProxyHandler class to
only watch the two required tables for it to function.

The more tables it monitors, the bigger the burden is on the OVSDB to
keep all the in-memory replicas updated. In special, the Chassis table
can generate a lot of events due to the agents health check mechanism
in the OVN driver so, removing it will prevent many events from being
sent across the fabric.

Closes-Bug: #1862648
Change-Id: Ib4fb9b445ed7fe4bce7bc05ae1b8dca264324718
Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
This commit is contained in:
Lucas Alvares Gomes 2020-02-06 13:28:34 +00:00
parent 2cd75e073a
commit b85c273639
3 changed files with 12 additions and 12 deletions

View File

@ -171,8 +171,7 @@ class MetadataAgent(object):
self._load_config()
# Launch the server that will act as a proxy between the VM's and Nova.
proxy = metadata_server.UnixDomainMetadataProxy(self.conf,
self.chassis)
proxy = metadata_server.UnixDomainMetadataProxy(self.conf)
proxy.run()
# Open the connection to OVN SB database.

View File

@ -27,17 +27,19 @@ class MetadataAgentOvnSbIdl(ovsdb_monitor.OvnIdl):
SCHEMA = 'OVN_Southbound'
def __init__(self, chassis, events=None):
def __init__(self, chassis=None, events=None, tables=None):
connection_string = config.get_ovn_sb_connection()
ovsdb_monitor._check_and_set_ssl_files(self.SCHEMA)
helper = self._get_ovsdb_helper(connection_string)
tables = ('Chassis', 'Encap', 'Port_Binding', 'Datapath_Binding',
'SB_Global')
if tables is None:
tables = ('Chassis', 'Encap', 'Port_Binding', 'Datapath_Binding',
'SB_Global')
for table in tables:
helper.register_table(table)
super(MetadataAgentOvnSbIdl, self).__init__(
None, connection_string, helper)
self.tables['Chassis'].condition = [['name', '==', chassis]]
if chassis and 'Chassis' in tables:
self.tables['Chassis'].condition = [['name', '==', chassis]]
if events:
self.notify_handler.watch_events(events)

View File

@ -44,9 +44,8 @@ MODE_MAP = {
class MetadataProxyHandler(object):
def __init__(self, conf, chassis=''):
def __init__(self, conf):
self.conf = conf
self.chassis = chassis
self.subscribe()
def subscribe(self):
@ -57,7 +56,8 @@ class MetadataProxyHandler(object):
def post_fork_initialize(self, resource, event, trigger, payload=None):
# We need to open a connection to OVN SouthBound database for
# each worker so that we can process the metadata requests.
self.sb_idl = ovsdb.MetadataAgentOvnSbIdl(chassis=self.chassis).start()
self.sb_idl = ovsdb.MetadataAgentOvnSbIdl(
tables=('Port_Binding', 'Datapath_Binding')).start()
@webob.dec.wsgify(RequestClass=webob.Request)
def __call__(self, req):
@ -162,9 +162,8 @@ class MetadataProxyHandler(object):
class UnixDomainMetadataProxy(object):
def __init__(self, conf, chassis=''):
def __init__(self, conf):
self.conf = conf
self.chassis = chassis
agent_utils.ensure_directory_exists_without_file(
cfg.CONF.metadata_proxy_socket)
@ -189,7 +188,7 @@ class UnixDomainMetadataProxy(object):
def run(self):
self.server = agent_utils.UnixDomainWSGIServer(
'networking-ovn-metadata-agent')
self.server.start(MetadataProxyHandler(self.conf, self.chassis),
self.server.start(MetadataProxyHandler(self.conf),
self.conf.metadata_proxy_socket,
workers=self.conf.metadata_workers,
backlog=self.conf.metadata_backlog,