[OVN] Initialize OVN agent in `start` method

The ``OVNAgentExtensionAPI`` and ``OVNAgentExtensionManager`` instances
create different threads instances. Now the OVN agent is using the
``oslo.service`` threading implementation (that uses ``cotyledon``).
This library creates a fork of the main process to execute the
``ServiceWrapper`` instance, where the agent is running. Any thread
should be created in the child process, at the
``oslo_service.service.Service.start`` method.

Closes-Bug: #2131540

Signed-off-by: Rodolfo Alonso Hernandez <ralonsoh@redhat.com>
Change-Id: I97d52e8fd2236b7d9210174d05f01c81a2edcd0d
This commit is contained in:
Rodolfo Alonso Hernandez 2025-11-14 15:29:18 +01:00 committed by Rodolfo Alonso
parent 2806f566f3
commit 5e92bbfa50
2 changed files with 18 additions and 3 deletions

View file

@ -103,9 +103,8 @@ class OVNNeutronAgent(service.Service):
self._chassis = None
self._chassis_id = None
self._ovn_bridge = None
self.ext_manager_api = ext_mgr.OVNAgentExtensionAPI()
self.ext_manager = ext_mgr.OVNAgentExtensionManager(self._conf)
self.ext_manager.initialize(None, 'ovn', self)
self.ext_manager_api = None
self.ext_manager = None
def __getitem__(self, name):
"""Return the named extension objet from ``self.ext_manager``"""
@ -234,7 +233,22 @@ class OVNNeutronAgent(service.Service):
'Chassis_Private', self.chassis,
('external_ids', external_ids)).execute(check_error=True)
def _initialize_ext_manager(self):
"""Initialize the externsion manager and the extension manager API.
This method must be called once, outside the ``__init__`` method and
at the beginning of the ``start`` method.
"""
if not self.ext_manager:
self.ext_manager_api = ext_mgr.OVNAgentExtensionAPI()
self.ext_manager = ext_mgr.OVNAgentExtensionManager(self._conf)
self.ext_manager.initialize(None, 'ovn', self)
def start(self):
# This must be the first operation in the `start` method.
self._initialize_ext_manager()
# Extension manager configuration.
self.ext_manager_api.ovs_idl = self._load_ovs_idl()
self.load_config()
# Before executing "_load_sb_idl", is is needed to execute

View file

@ -105,6 +105,7 @@ class TestOVNNeutronAgentBase(base.TestOVNFunctionalBase):
'wait'), \
mock.patch.object(ovn_neutron_agent.OVNNeutronAgent,
'_load_ovs_idl') as mock_load_ovs_idl:
agt._initialize_ext_manager()
mock_load_ovs_idl.return_value = self._create_ovs_idl(agt)
agt.start()
external_ids = agt.sb_idl.db_get(