[eventlet-removal] Remove the usage of eventlet from the OVN maintenance worker

Related-Bug: #2087953
Change-Id: I511e7f5dc0c8d92a376cd73819007270f2a915ca
This commit is contained in:
Rodolfo Alonso Hernandez
2025-05-25 20:13:04 +00:00
parent 5292b13bbd
commit d17e39e528
7 changed files with 43 additions and 17 deletions

View File

@@ -134,6 +134,12 @@ The Neutron API consists of the following executables:
mechanism driver.
.. note::
Right now, only the API server and the OVN maintenance task are running
without eventlet.
ML2/OVN
~~~~~~~
@@ -153,11 +159,20 @@ restarted, this method will provide the same register UUID and the previous
register (if present in the database) will be overwritten.
OVN maintenance task
~~~~~~~~~~~~~~~~~~~~
The ``OvnDbSynchronizer`` class now uses a ``threading.Thread`` to spawn the
``do_sync`` function. This is used by the Northbound and Southbound
synchronizer classes (``OvnNbSynchronizer``, ``OvnSbSynchronizer``).
.. note::
Right now, only the API server is running without eventlet.
The ``stop`` method needs to be refactored, along with the function
``do_sync`` implemented in each child class. The ``stop`` method needs to
support a fast exit mechanism to stop as fast as possible the running
synchronization.
References

View File

@@ -11,7 +11,6 @@
# under the License.
from neutron import server
from neutron.server import ovn_maintenance
from neutron.server import periodic_eventlet
from neutron.server import rpc_eventlet
from neutron.server import wsgi_eventlet
@@ -27,7 +26,3 @@ def main_rpc_eventlet():
def main_periodic_eventlet():
server.boot_server(periodic_eventlet.eventlet_periodic_workers)
def main_ovn_maintenance_eventlet():
return server.boot_server(ovn_maintenance.eventlet_ovn_maintenance_worker)

View File

@@ -13,9 +13,19 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron import server
from neutron.server import api
# NOTE(ralonsoh): remove once the default backend is ``BackendType.THREADING``
import oslo_service.backend as service
service.init_backend(service.BackendType.THREADING)
# pylint: disable=wrong-import-position
from neutron import server # noqa: E402
from neutron.server import api # noqa: E402
from neutron.server import ovn_maintenance # noqa: E402
def main_api_uwsgi():
return server.boot_server(api.api_server)
def main_ovn_maintenance():
return server.boot_server(ovn_maintenance.ovn_maintenance_worker)

View File

@@ -13,8 +13,9 @@
import abc
from datetime import datetime
import itertools
import threading
import time
from eventlet import greenthread
from neutron_lib.api.definitions import segment as segment_def
from neutron_lib import constants
from neutron_lib import context
@@ -47,17 +48,22 @@ class OvnDbSynchronizer(metaclass=abc.ABCMeta):
self.ovn_driver = ovn_driver
self.ovn_api = ovn_api
self.core_plugin = core_plugin
self._thread = None
def sync(self, delay_seconds=10):
self._gt = greenthread.spawn_after_local(delay_seconds, self.do_sync)
time.sleep(delay_seconds)
self._thread = threading.Thread(target=self.do_sync)
self._thread.start()
@abc.abstractmethod
def do_sync(self):
"""Method to sync the OVN DB."""
def stop(self):
# TODO(ralonsoh): this method a the function executed in the thread
# should support a fast exit way.
try:
self._gt.kill()
self._thread.join()
except AttributeError:
# Haven't started syncing
pass

View File

@@ -24,8 +24,8 @@ from neutron import service
LOG = log.getLogger(__name__)
def eventlet_ovn_maintenance_worker():
LOG.info('Eventlet OVN maintenance process starting...')
def ovn_maintenance_worker():
LOG.info('OVN maintenance process starting...')
try:
manager.init()

View File

@@ -284,7 +284,7 @@ def _start_workers(workers, neutron_api=None):
worker_launcher = neutron_api.wsgi_app.process_launcher
if worker_launcher is None:
worker_launcher = common_service.ProcessLauncher(
cfg.CONF, wait_interval=1.0, restart_method='mutate'
cfg.CONF, restart_method='mutate',
)
# add extra process worker and spawn there all workers with

View File

@@ -55,7 +55,7 @@ console_scripts =
neutron-periodic-workers = neutron.cmd.eventlet.server:main_periodic_eventlet
neutron-status = neutron.cmd.status:main
neutron-ovn-agent = neutron.cmd.agents.ovn_neutron_agent:main
neutron-ovn-maintenance-worker = neutron.cmd.eventlet.server:main_ovn_maintenance_eventlet
neutron-ovn-maintenance-worker = neutron.cmd.server:main_ovn_maintenance
neutron-ovn-metadata-agent = neutron.cmd.agents.ovn_metadata:main
neutron-ovn-migration-mtu = neutron.cmd.ovn.migration_mtu:main
neutron-ovn-db-sync-util = neutron.cmd.ovn.neutron_ovn_db_sync_util:main