Merge "[OVN] Reduce the number of watched tables in MetadataProxyHandler"
This commit is contained in:
commit
75f6f624bc
|
@ -171,8 +171,7 @@ class MetadataAgent(object):
|
||||||
self._load_config()
|
self._load_config()
|
||||||
|
|
||||||
# Launch the server that will act as a proxy between the VM's and Nova.
|
# Launch the server that will act as a proxy between the VM's and Nova.
|
||||||
proxy = metadata_server.UnixDomainMetadataProxy(self.conf,
|
proxy = metadata_server.UnixDomainMetadataProxy(self.conf)
|
||||||
self.chassis)
|
|
||||||
proxy.run()
|
proxy.run()
|
||||||
|
|
||||||
# Open the connection to OVN SB database.
|
# Open the connection to OVN SB database.
|
||||||
|
|
|
@ -27,17 +27,19 @@ class MetadataAgentOvnSbIdl(ovsdb_monitor.OvnIdl):
|
||||||
|
|
||||||
SCHEMA = 'OVN_Southbound'
|
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()
|
connection_string = config.get_ovn_sb_connection()
|
||||||
ovsdb_monitor._check_and_set_ssl_files(self.SCHEMA)
|
ovsdb_monitor._check_and_set_ssl_files(self.SCHEMA)
|
||||||
helper = self._get_ovsdb_helper(connection_string)
|
helper = self._get_ovsdb_helper(connection_string)
|
||||||
tables = ('Chassis', 'Encap', 'Port_Binding', 'Datapath_Binding',
|
if tables is None:
|
||||||
'SB_Global')
|
tables = ('Chassis', 'Encap', 'Port_Binding', 'Datapath_Binding',
|
||||||
|
'SB_Global')
|
||||||
for table in tables:
|
for table in tables:
|
||||||
helper.register_table(table)
|
helper.register_table(table)
|
||||||
super(MetadataAgentOvnSbIdl, self).__init__(
|
super(MetadataAgentOvnSbIdl, self).__init__(
|
||||||
None, connection_string, helper)
|
None, connection_string, helper)
|
||||||
self.tables['Chassis'].condition = [['name', '==', chassis]]
|
if chassis and 'Chassis' in tables:
|
||||||
|
self.tables['Chassis'].condition = [['name', '==', chassis]]
|
||||||
if events:
|
if events:
|
||||||
self.notify_handler.watch_events(events)
|
self.notify_handler.watch_events(events)
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,8 @@ MODE_MAP = {
|
||||||
|
|
||||||
class MetadataProxyHandler(object):
|
class MetadataProxyHandler(object):
|
||||||
|
|
||||||
def __init__(self, conf, chassis=''):
|
def __init__(self, conf):
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.chassis = chassis
|
|
||||||
self.subscribe()
|
self.subscribe()
|
||||||
|
|
||||||
def subscribe(self):
|
def subscribe(self):
|
||||||
|
@ -57,7 +56,8 @@ class MetadataProxyHandler(object):
|
||||||
def post_fork_initialize(self, resource, event, trigger, payload=None):
|
def post_fork_initialize(self, resource, event, trigger, payload=None):
|
||||||
# We need to open a connection to OVN SouthBound database for
|
# We need to open a connection to OVN SouthBound database for
|
||||||
# each worker so that we can process the metadata requests.
|
# 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)
|
@webob.dec.wsgify(RequestClass=webob.Request)
|
||||||
def __call__(self, req):
|
def __call__(self, req):
|
||||||
|
@ -162,9 +162,8 @@ class MetadataProxyHandler(object):
|
||||||
|
|
||||||
class UnixDomainMetadataProxy(object):
|
class UnixDomainMetadataProxy(object):
|
||||||
|
|
||||||
def __init__(self, conf, chassis=''):
|
def __init__(self, conf):
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.chassis = chassis
|
|
||||||
agent_utils.ensure_directory_exists_without_file(
|
agent_utils.ensure_directory_exists_without_file(
|
||||||
cfg.CONF.metadata_proxy_socket)
|
cfg.CONF.metadata_proxy_socket)
|
||||||
|
|
||||||
|
@ -189,7 +188,7 @@ class UnixDomainMetadataProxy(object):
|
||||||
def run(self):
|
def run(self):
|
||||||
self.server = agent_utils.UnixDomainWSGIServer(
|
self.server = agent_utils.UnixDomainWSGIServer(
|
||||||
'networking-ovn-metadata-agent')
|
'networking-ovn-metadata-agent')
|
||||||
self.server.start(MetadataProxyHandler(self.conf, self.chassis),
|
self.server.start(MetadataProxyHandler(self.conf),
|
||||||
self.conf.metadata_proxy_socket,
|
self.conf.metadata_proxy_socket,
|
||||||
workers=self.conf.metadata_workers,
|
workers=self.conf.metadata_workers,
|
||||||
backlog=self.conf.metadata_backlog,
|
backlog=self.conf.metadata_backlog,
|
||||||
|
|
Loading…
Reference in New Issue