[eventlet-removal][OVN] Require wsgi start-time in the config

Currently there is one single method to run the Neutron API that is
using uWSGI. This method requires a specific hash ring manager
initialization, different to the eventlet server based.

Because the second has been removed and is no longer available, as
long as Neutron continues the effors of removing eventlet from the
source code, the second way to initialize the hash ring manager
is removed.

Related-Bug: #2083570
Change-Id: I59b25093df9cf5aa77767492a5b9008bfa11cc07
This commit is contained in:
Rodolfo Alonso Hernandez
2025-01-24 11:52:11 +00:00
committed by Rodolfo Alonso
parent 3ff599700c
commit b0c02c2892
4 changed files with 51 additions and 29 deletions

View File

@@ -69,7 +69,16 @@ Neutron API
The Neutron API currently can be executed only with the uWSGI module; the
eventlet executor has been deprecated, although the code has not been removed
from the repository yet.
from the repository yet. It is now mandatory to define the configuration
variable ``start-time`` in the uWSGI configuration file, using the magic
variable [1]_ "%t" that provides the *unix time (in seconds, gathered at
instance startup)*.
.. code::
[uwsgi]
start-time = %t
The Neutron API consists of the following executables:
@@ -89,3 +98,11 @@ The Neutron API consists of the following executables:
.. note::
Right now, only the API server is running without eventlet.
References
----------
.. [1] https://uwsgi-docs.readthedocs.io/en/latest/Configuration.html#magic-variables

View File

@@ -124,10 +124,6 @@ class OVNMechanismDriver(api.MechanismDriver):
self._maintenance_thread = None
self._hash_ring_thread = None
self._hash_ring_probe_event = multiprocessing.Event()
self._start_time = wsgi_utils.get_start_time()
if self._start_time:
LOG.info('Server start time: %s',
str(n_utils.ts_to_datetime(self._start_time)))
self.node_uuid = None
self.hash_ring_group = ovn_const.HASH_RING_ML2_GROUP
self.sg_enabled = ovn_acl.is_sg_enabled()
@@ -148,6 +144,7 @@ class OVNMechanismDriver(api.MechanismDriver):
self.qos_driver = qos_driver.OVNQosDriver.create(self)
self.trunk_driver = trunk_driver.OVNTrunkDriver.create(self)
self.log_driver = log_driver.register(self)
self._start_time = None
@property
def nb_schema_helper(self):
@@ -188,6 +185,24 @@ class OVNMechanismDriver(api.MechanismDriver):
def sb_ovn(self, val):
self._sb_ovn = val
@property
def start_time(self):
if self._start_time:
return self._start_time
self._start_time = wsgi_utils.get_start_time()
if not self._start_time:
LOG.warning('uWSGI must provide a start time using the '
'configuration parameter "start-time %t" in the '
'configuration file')
# NOTE(ralonsoh): this is happening if the uWSGI configuration file
# does not have the "start-time %t" parameter or when using the
# Neutron API eventlet server, still in use in the grenade
# skip-level jobs. This should be removed in the F release.
self._start_time = wsgi_utils.get_start_time(current_time=True)
return self._start_time
def get_supported_vif_types(self):
vif_types = set()
for ch in self.sb_ovn.chassis_list().execute(check_error=True):
@@ -325,12 +340,7 @@ class OVNMechanismDriver(api.MechanismDriver):
sh = oslo_service.SignalHandler()
atexit.register(self._remove_node_from_hash_ring)
sh.add_handler("SIGTERM", self._remove_node_from_hash_ring)
admin_context = n_context.get_admin_context()
if self._start_time:
self._setup_hash_ring_start_time(admin_context)
else:
self._setup_hash_ring_event(admin_context)
self._init_hash_ring(n_context.get_admin_context())
self._register_hash_ring_maintenance()
def _register_hash_ring_maintenance(self):
@@ -346,24 +356,12 @@ class OVNMechanismDriver(api.MechanismDriver):
LOG.info('Hash Ring probing thread for node %s has started',
self.node_uuid)
def _setup_hash_ring_event(self, context):
LOG.debug('Hash Ring setup using multiprocess event lock')
if not self._hash_ring_probe_event.is_set():
# Clear existing entries. This code section should be executed
# only once per node (chassis); the multiprocess event should be
# set just after the ``is_set`` check.
self._hash_ring_probe_event.set()
ovn_hash_ring_db.remove_nodes_from_host(context,
self.hash_ring_group)
self.node_uuid = ovn_hash_ring_db.add_node(context,
self.hash_ring_group)
@db_api.retry_if_session_inactive()
@db_api.CONTEXT_WRITER
def _setup_hash_ring_start_time(self, context):
LOG.debug('Hash Ring setup using WSGI start time')
# Delete all node registers without created_at=self._start_time
created_at = n_utils.ts_to_datetime(self._start_time)
def _init_hash_ring(self, context):
LOG.debug('Hash Ring setup using WSGI start time %s',
str(n_utils.ts_to_datetime(self.start_time)))
created_at = n_utils.ts_to_datetime(self.start_time)
ovn_hash_ring_db.remove_nodes_from_host(
context, self.hash_ring_group, created_at=created_at)
self.node_uuid = ovn_hash_ring_db.add_node(

View File

@@ -62,7 +62,7 @@ VHOSTUSER_VIF_DETAILS = {
class TestOVNMechanismDriver(base.TestOVNFunctionalBase):
def test__setup_hash_ring_start_time(self):
def test__init_hash_ring(self):
# Create a differentiated OVN hash ring name.
ring_group = uuidutils.generate_uuid()
self.mech_driver.hash_ring_group = ring_group
@@ -81,7 +81,7 @@ class TestOVNMechanismDriver(base.TestOVNFunctionalBase):
start_time = timeutils.utcnow()
self.mech_driver._start_time = int(start_time.timestamp())
for _ in range(3):
self.mech_driver._setup_hash_ring_start_time(self.context)
self.mech_driver._init_hash_ring(self.context)
ovn_hrs = ovn_hash_ring_db.get_nodes(self.context, ring_group)
self.assertEqual(3, len(ovn_hrs))

View File

@@ -0,0 +1,7 @@
---
upgrade:
- |
Now it is mandatory to define the ``start-time=%t`` variable in the uWSGI
configuration file. It will provide the unix time in seconds, gathered at
instance startup. This value is the same for all workers and is persistent
if the uWSGI process restarts any of them.