Add a new option to enable signals

When running behind a wsgi server like apache/mod_wsgi, neutron should
not register on Signals, it will overlap with the Signals registered by
the wsgi server.

Related-Bug: #2021814

Change-Id: I3c74846a8337d019f1ab6759ebb03f18c3f00238
Signed-off-by: Arnaud Morin <arnaud.morin@ovhcloud.com>
This commit is contained in:
Arnaud Morin 2023-05-30 16:48:32 +02:00 committed by Arnaud Morin
parent 0ceecd3282
commit 878ea0dfd5
4 changed files with 22 additions and 3 deletions

View File

@ -165,6 +165,10 @@ core_opts = [
help=_('IPv6 address of this host. If no address is provided '
'and one cannot be determined, ::1 will be '
'used.')),
cfg.BoolOpt('enable_signals', default=True,
help=_('If False, neutron-server will not listen for signals '
'like SIGINT or SIGTERM. This is useful when running '
'behind a WSGI server like apache/mod_wsgi.')),
]
core_cli_opts = [

View File

@ -154,10 +154,13 @@ class OVOServerRpcInterface(object):
Generates RPC callback notifications on ML2 object changes.
"""
def __init__(self):
def __init__(self, enable_signals=True):
self._rpc_pusher = resources_rpc.ResourcesPushRpcApi()
self._setup_change_handlers()
_setup_change_handlers_cleanup()
# When running behind wsgi server (like apache2/mod_wsgi)
# we should not register signals
if enable_signals:
_setup_change_handlers_cleanup()
LOG.debug("ML2 OVO RPC backend initialized.")
def _setup_change_handlers(self):

View File

@ -407,7 +407,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self.ovo_notifier = None
rpc_workers = conf_service.get_rpc_workers()
if rpc_workers is None or rpc_workers >= 1:
self.ovo_notifier = ovo_rpc.OVOServerRpcInterface()
self.ovo_notifier = ovo_rpc.OVOServerRpcInterface(
cfg.CONF.enable_signals)
self.notifier = rpc.AgentNotifierApi(topics.AGENT)
if cfg.CONF.enable_traditional_dhcp:
self.agent_notifiers[const.AGENT_TYPE_DHCP] = (

View File

@ -0,0 +1,11 @@
---
features:
- |
A new config option ``enable_signals`` has been added to neutron.conf to
control whether neutron-server registers signal handlers or not (like
SIGTERM, etc). The default value for this new option is True to mimic the
original behavior of registering signal handlers.
The recommendation is to set this option to False when neutron-server is
running behind a WSGI server, because in that situation the signals are
taken over by the WSGI server and neutron will print a stack trace letting
us know that signals cannot be registered.