Skip to content

Commit a5e1a3d

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "OVNL3RouterPlugin register events in Neutron API workers" into stable/2026.1
2 parents d825eaf + 05dd00c commit a5e1a3d

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

neutron/services/ovn_l3/plugin.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
from neutron._i18n import _
3838
from neutron.api.rpc.agentnotifiers import utils as notifier_utils
39+
from neutron.api import wsgi
3940
from neutron.common.ovn import constants as ovn_const
4041
from neutron.common.ovn import extensions
4142
from neutron.common.ovn import utils
@@ -185,11 +186,15 @@ def _post_fork_initialize(self, resource, event, trigger, payload=None):
185186
if not self._nb_ovn or not self._sb_ovn:
186187
raise ovn_l3_exc.MechanismDriverOVNNotReady()
187188

188-
# Register needed events.
189-
self._nb_ovn.idl.notify_handler.watch_events([
190-
ovsdb_monitor.LogicalRouterPortEvent(self),
191-
ovsdb_monitor.LogicalRouterPortGatewayChassisEvent(self),
192-
])
189+
# Register needed events, only for the Neutron API workers.
190+
# TODO(ralonsoh): once [1] is released and required in Neutron, it
191+
# won't be needed the ``get_method_class`` method.
192+
# [1] https://review.opendev.org/c/openstack/neutron-lib/+/988563
193+
if utils.get_method_class(trigger) == wsgi.WorkerService:
194+
self._nb_ovn.idl.notify_handler.watch_events([
195+
ovsdb_monitor.LogicalRouterPortEvent(self),
196+
ovsdb_monitor.LogicalRouterPortGatewayChassisEvent(self),
197+
])
193198

194199
def _add_neutron_router_interface(self, context, router_id,
195200
interface_info):

neutron/tests/functional/services/ovn_l3/test_ovsdb_monitor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from neutron_lib.plugins import constants as plugin_constants
1919
from neutron_lib.plugins import directory
2020

21+
from neutron.api import wsgi
2122
from neutron.common.ovn import utils as ovn_utils
2223
from neutron.common import utils as n_utils
2324
from neutron.services.bgp import constants as bgp_constants
@@ -34,7 +35,8 @@ def setUp(self, **kwargs):
3435
super().setUp(**kwargs)
3536
self.chassis = self.add_fake_chassis('ovs-host1')
3637
self.l3_plugin = directory.get_plugin(plugin_constants.L3)
37-
self.l3_plugin._post_fork_initialize(mock.ANY, mock.ANY, mock.ANY)
38+
self.l3_plugin._post_fork_initialize(
39+
mock.ANY, mock.ANY, wsgi.WorkerService)
3840
self.ext_api = test_extensions.setup_extensions_middleware(
3941
test_l3.L3TestExtensionManager())
4042
kwargs = {'arg_list': (external_net.EXTERNAL,),
@@ -201,7 +203,8 @@ def setUp(self, **kwargs):
201203
super().setUp(**kwargs)
202204
self.chassis = self.add_fake_chassis('ovs-host1')
203205
self.l3_plugin = directory.get_plugin(plugin_constants.L3)
204-
self.l3_plugin._post_fork_initialize(mock.ANY, mock.ANY, mock.ANY)
206+
self.l3_plugin._post_fork_initialize(
207+
mock.ANY, mock.ANY, wsgi.WorkerService)
205208
self.ext_api = test_extensions.setup_extensions_middleware(
206209
test_l3.L3TestExtensionManager())
207210
kwargs = {'arg_list': (external_net.EXTERNAL,),
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
fixes:
3+
- |
4+
The ``OVNL3RouterPlugin`` now registers OVN OVSDB events
5+
(``LogicalRouterPortEvent`` and ``RouterHAChassisGroupEvent``) only in
6+
Neutron API workers (``WorkerService`` instances). Previously these events
7+
were registered by every worker type that called
8+
``_post_fork_initialize``, which could lead to unexpected event processing
9+
in maintenance or other non-API workers.

0 commit comments

Comments
 (0)