[ovn]Set NB/SB "connection" inactivity probe support multi addresses
When OVN is clustered, connection be set multiple addresses, inactivity probe cannot currently be set correctly. this patch fix it. Closes-bug: #1958364 Change-Id: I5f83d6f47dc60b849cca5830ec3f77c15a446530
This commit is contained in:
parent
f324ddf769
commit
0124dab423
@ -36,7 +36,12 @@ ovn_opts = [
|
|||||||
'Use ssl:IP:PORT for SSL connection. The '
|
'Use ssl:IP:PORT for SSL connection. The '
|
||||||
'ovn_nb_private_key, ovn_nb_certificate and '
|
'ovn_nb_private_key, ovn_nb_certificate and '
|
||||||
'ovn_nb_ca_cert are mandatory.\n'
|
'ovn_nb_ca_cert are mandatory.\n'
|
||||||
'Use unix:FILE for unix domain socket connection.')),
|
'Use unix:FILE for unix domain socket connection.\n'
|
||||||
|
'Multiple connection can be specified by a comma '
|
||||||
|
'separated string. See also: '
|
||||||
|
'https://github.com/openvswitch/ovs/blob'
|
||||||
|
'/ab4d3bfbef37c31331db5a9dbe7c22eb8d5e5e5f'
|
||||||
|
'/python/ovs/db/idl.py#L215-L216')),
|
||||||
cfg.StrOpt('ovn_nb_private_key',
|
cfg.StrOpt('ovn_nb_private_key',
|
||||||
default='',
|
default='',
|
||||||
help=_('The PEM file with private key for SSL connection to '
|
help=_('The PEM file with private key for SSL connection to '
|
||||||
@ -56,7 +61,12 @@ ovn_opts = [
|
|||||||
'Use ssl:IP:PORT for SSL connection. The '
|
'Use ssl:IP:PORT for SSL connection. The '
|
||||||
'ovn_sb_private_key, ovn_sb_certificate and '
|
'ovn_sb_private_key, ovn_sb_certificate and '
|
||||||
'ovn_sb_ca_cert are mandatory.\n'
|
'ovn_sb_ca_cert are mandatory.\n'
|
||||||
'Use unix:FILE for unix domain socket connection.')),
|
'Use unix:FILE for unix domain socket connection.\n'
|
||||||
|
'Multiple connection can be specified by a comma '
|
||||||
|
'separated string. See also: '
|
||||||
|
'https://github.com/openvswitch/ovs/blob'
|
||||||
|
'/ab4d3bfbef37c31331db5a9dbe7c22eb8d5e5e5f'
|
||||||
|
'/python/ovs/db/idl.py#L215-L216')),
|
||||||
cfg.StrOpt('ovn_sb_private_key',
|
cfg.StrOpt('ovn_sb_private_key',
|
||||||
default='',
|
default='',
|
||||||
help=_('The PEM file with private key for SSL connection to '
|
help=_('The PEM file with private key for SSL connection to '
|
||||||
|
@ -310,19 +310,24 @@ class OVNMechanismDriver(api.MechanismDriver):
|
|||||||
(ovn_conf.get_ovn_sb_connection(), self.sb_schema_helper,
|
(ovn_conf.get_ovn_sb_connection(), self.sb_schema_helper,
|
||||||
impl_idl_ovn.OvsdbSbOvnIdl)]
|
impl_idl_ovn.OvsdbSbOvnIdl)]
|
||||||
for connection, schema, klass in dbs:
|
for connection, schema, klass in dbs:
|
||||||
target = ovn_utils.connection_config_to_target_string(connection)
|
targets = []
|
||||||
if not target:
|
for _conn in idlutils.parse_connection(connection):
|
||||||
|
target = ovn_utils.connection_config_to_target_string(_conn)
|
||||||
|
if target:
|
||||||
|
targets.append(target)
|
||||||
|
if not targets:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
idl = ovsdb_monitor.BaseOvnIdl.from_server(connection, schema)
|
idl = ovsdb_monitor.BaseOvnIdl.from_server(connection, schema)
|
||||||
with ovsdb_monitor.short_living_ovsdb_api(klass, idl) as idl_api:
|
with ovsdb_monitor.short_living_ovsdb_api(klass, idl) as idl_api:
|
||||||
conn = idlutils.row_by_value(idl_api, 'Connection', 'target',
|
for target in targets:
|
||||||
target, None)
|
conn = idlutils.row_by_value(idl_api, 'Connection',
|
||||||
|
'target', target, None)
|
||||||
if conn:
|
if conn:
|
||||||
idl_api.db_set(
|
idl_api.db_set(
|
||||||
'Connection', target,
|
'Connection', target,
|
||||||
('inactivity_probe', int(inactivity_probe))).execute(
|
('inactivity_probe', int(inactivity_probe))
|
||||||
check_error=True)
|
).execute(check_error=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def should_post_fork_initialize(worker_class):
|
def should_post_fork_initialize(worker_class):
|
||||||
|
@ -376,3 +376,39 @@ class TestOvnIdlProbeInterval(base.TestOVNFunctionalBase):
|
|||||||
interval = ovn_conf.get_ovn_ovsdb_probe_interval()
|
interval = ovn_conf.get_ovn_ovsdb_probe_interval()
|
||||||
for idl in idls:
|
for idl in idls:
|
||||||
self.assertEqual(interval, idl._session.reconnect.probe_interval)
|
self.assertEqual(interval, idl._session.reconnect.probe_interval)
|
||||||
|
|
||||||
|
|
||||||
|
class TestOvnIdlConnections(base.TestOVNFunctionalBase):
|
||||||
|
def setUp(self):
|
||||||
|
temp_dir = self.useFixture(og_fixtures.TempDir()).path
|
||||||
|
install_share_path = self._get_install_share_path()
|
||||||
|
mgr = self.useFixture(
|
||||||
|
process.OvsdbServer(temp_dir, install_share_path,
|
||||||
|
ovn_nb_db=True, ovn_sb_db=True,
|
||||||
|
protocol='tcp'))
|
||||||
|
connection = mgr.get_ovsdb_connection_path
|
||||||
|
|
||||||
|
nb_conns = connection()
|
||||||
|
sb_conns = connection(db_type='sb')
|
||||||
|
# add fake address, idl support multiple addresses, as long as there
|
||||||
|
# is an available address, it will run successfully.
|
||||||
|
nb_conns += ',tcp:192.168.0.1:6641'
|
||||||
|
sb_conns += ',tcp:192.168.0.1:6642'
|
||||||
|
self.connections = {'OVN_Northbound': nb_conns,
|
||||||
|
'OVN_Southbound': sb_conns}
|
||||||
|
super().setUp()
|
||||||
|
|
||||||
|
def test_ovsdb_connections(self):
|
||||||
|
klasses = {
|
||||||
|
ovsdb_monitor.OvnNbIdl: ('OVN_Northbound',
|
||||||
|
{'driver': self.mech_driver}),
|
||||||
|
ovsdb_monitor.OvnSbIdl: ('OVN_Southbound',
|
||||||
|
{'driver': self.mech_driver})}
|
||||||
|
for kls, (schema, kwargs) in klasses.items():
|
||||||
|
conns = self.connections[schema]
|
||||||
|
idl = kls.from_server(
|
||||||
|
conns,
|
||||||
|
idlutils.get_schema_helper(conns, schema),
|
||||||
|
**kwargs)
|
||||||
|
self.assertEqual(set(idlutils.parse_connection(conns)),
|
||||||
|
set(idl._session.remotes))
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Ovn configuration items "ovn_nb_connection" and "ovn_sb_connection"
|
||||||
|
can set multiple addresses separated by commas. Setting NB/SB
|
||||||
|
"connection" inactivity probe can also work well, if multiple
|
||||||
|
connection be specified.
|
Loading…
x
Reference in New Issue
Block a user