Merge "Add a new option to enable signals"

This commit is contained in:
Zuul
2023-12-08 18:32:12 +00:00
committed by Gerrit Code Review
4 changed files with 22 additions and 3 deletions

View File

@@ -164,6 +164,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

@@ -410,7 +410,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.