Revert "[OVN] Set NB/SB "connection" inactivity probe"

This reverts commit 28f3017a90.

Reason for revert: It breaks Neutron server to start if OVN
                   database is large. Also Neutron server shouldn't
                   be configuring other services, it should be done
                   rather by an installer.

Change-Id: Ia1dc8072ecec1c019dd02039dadd78d544dbd843
(cherry picked from commit 30d1a40c50)
This commit is contained in:
Jakub Libosvar 2022-09-10 21:27:15 +00:00 committed by Krzysztof Tomaszewski
parent 98e2fd47fe
commit c968f40967
5 changed files with 0 additions and 113 deletions

View File

@ -613,23 +613,3 @@ def parse_ovn_lb_port_forwarding(ovn_rtr_lb_pfs):
def get_network_name_from_datapath(datapath):
return datapath.external_ids['name'].replace('neutron-', '')
def connection_config_to_target_string(connection_config):
"""Converts the Neutron NB/SB connection parameter to the OVN target string
:param connection_config: Neutron OVN config parameter for the OVN NB or SB
database. See "ovn_sb_connection" or
"ovn_nb_connection" params.
:returns: (String) OVN NB/SB ``connection.target`` column value.
"""
regex = re.compile(r'^(?P<proto>\w+)\:((?P<ip>.+)\:(?P<port>\d+)|'
r'(?P<file>[\w\/\.]+))')
m = regex.match(connection_config)
if m:
_dict = m.groupdict()
if _dict['ip'] and _dict['port']:
return ('p' + _dict['proto'] + ':' + _dict['port'] + ':' +
_dict['ip'])
elif _dict['file']:
return 'p' + _dict['proto'] + ':' + _dict['file']

View File

@ -40,7 +40,6 @@ from oslo_config import cfg
from oslo_db import exception as os_db_exc
from oslo_log import log
from oslo_utils import timeutils
from ovsdbapp.backend.ovs_idl import idlutils
from neutron._i18n import _
from neutron.common.ovn import acl as ovn_acl
@ -237,7 +236,6 @@ class OVNMechanismDriver(api.MechanismDriver):
atexit.register(self._clean_hash_ring)
signal.signal(signal.SIGTERM, self._clean_hash_ring)
self._create_neutron_pg_drop()
self._set_inactivity_probe()
def _create_neutron_pg_drop(self):
"""Create neutron_pg_drop Port Group.
@ -274,28 +272,6 @@ class OVNMechanismDriver(api.MechanismDriver):
else:
raise
def _set_inactivity_probe(self):
"""Set 'connection.inactivity_probe' in NB and SB databases"""
inactivity_probe = ovn_conf.get_ovn_ovsdb_probe_interval()
dbs = [(ovn_conf.get_ovn_nb_connection(), 'OVN_Northbound',
impl_idl_ovn.OvsdbNbOvnIdl),
(ovn_conf.get_ovn_sb_connection(), 'OVN_Southbound',
impl_idl_ovn.OvsdbSbOvnIdl)]
for connection, schema, klass in dbs:
target = ovn_utils.connection_config_to_target_string(connection)
if not target:
continue
idl = ovsdb_monitor.BaseOvnIdl.from_server(connection, schema)
with ovsdb_monitor.short_living_ovsdb_api(klass, idl) as idl_api:
conn = idlutils.row_by_value(idl_api, 'Connection', 'target',
target, None)
if conn:
idl_api.db_set(
'Connection', target,
('inactivity_probe', int(inactivity_probe))).execute(
check_error=True)
@staticmethod
def should_post_fork_initialize(worker_class):
return worker_class in (neutron.wsgi.WorkerService,

View File

@ -669,7 +669,6 @@ class OvnSbIdl(OvnIdlDistributedLock):
helper.register_table('Encap')
helper.register_table('Port_Binding')
helper.register_table('Datapath_Binding')
helper.register_table('Connection')
helper.register_columns('SB_Global', ['external_ids'])
try:
return cls(driver, connection_string, helper, leader_only=False)

View File

@ -27,7 +27,6 @@ from oslo_utils import uuidutils
from ovsdbapp.backend.ovs_idl import event
from ovsdbapp.tests.functional import base as ovs_base
from neutron.agent.linux import utils as linux_utils
from neutron.common.ovn import constants as ovn_const
from neutron.common.ovn import utils
from neutron.common import utils as n_utils
@ -999,54 +998,3 @@ class TestAgentApi(base.TestOVNFunctionalBase):
self.plugin.delete_agent(self.context, agent_id)
self.assertRaises(agent_exc.AgentNotFound, self.plugin.get_agent,
self.context, agent_id)
class ConnectionInactivityProbeSetEvent(event.WaitEvent):
"""Wait for a Connection (NB/SB) to have the inactivity probe set"""
ONETIME = False
def __init__(self, target, inactivity_probe):
table = 'Connection'
events = (self.ROW_UPDATE,)
super().__init__(events, table, None)
self.event_name = "ConnectionEvent"
self.target = target
self.inactivity_probe = inactivity_probe
def match_fn(self, event, row, old):
return row.target in self.target
def run(self, event, row, old):
if (row.inactivity_probe and
row.inactivity_probe[0] == self.inactivity_probe):
self.event.set()
class TestSetInactivityProbe(base.TestOVNFunctionalBase):
def setUp(self):
super().setUp()
self.dbs = [(ovn_conf.get_ovn_nb_connection(), 'ptcp:1000:1.2.3.4'),
(ovn_conf.get_ovn_sb_connection(), 'ptcp:1001:1.2.3.4')]
linux_utils.execute(
['ovn-nbctl', '--db=%s' % self.dbs[0][0],
'set-connection', self.dbs[0][1]], run_as_root=True)
linux_utils.execute(
['ovn-sbctl', '--db=%s' % self.dbs[1][0],
'set-connection', self.dbs[1][1]], run_as_root=True)
def test_1(self):
mock.patch.object(ovn_conf, 'get_ovn_ovsdb_probe_interval',
return_value='2500').start()
nb_connection = ConnectionInactivityProbeSetEvent(self.dbs[0][1], 2500)
sb_connection = ConnectionInactivityProbeSetEvent(self.dbs[1][1], 2500)
self.nb_api.idl.notify_handler.watch_event(nb_connection)
self.sb_api.idl.notify_handler.watch_event(sb_connection)
with mock.patch.object(utils, 'connection_config_to_target_string') \
as mock_target:
mock_target.side_effect = [self.dbs[0][1], self.dbs[1][1]]
self.mech_driver._set_inactivity_probe()
self.assertTrue(nb_connection.wait())
self.assertTrue(sb_connection.wait())

View File

@ -320,22 +320,6 @@ class TestDHCPUtils(base.BaseTestCase):
self.assertEqual(expected_options, options)
class TestConnectionConfigToTargetString(base.BaseTestCase):
def test_strings(self):
config_target = (
('ssl:1.2.3.4:5678', 'pssl:5678:1.2.3.4'),
('tcp:1.2.3.4:5678', 'ptcp:5678:1.2.3.4'),
('ssl:[::1]:5678', 'pssl:5678:[::1]'),
('tcp:[::1]:5678', 'ptcp:5678:[::1]'),
('unix:/var/run/ovs/db.sock', 'punix:/var/run/ovs/db.sock'),
('wrong_value', None))
for config, target in config_target:
output = utils.connection_config_to_target_string(config)
self.assertEqual(target, output)
class TestGetDhcpDnsServers(base.BaseTestCase):
def test_ipv4(self):