diff --git a/doc/source/admin/config-wsgi.rst b/doc/source/admin/config-wsgi.rst index 6d257b2225c..096ead1cab1 100644 --- a/doc/source/admin/config-wsgi.rst +++ b/doc/source/admin/config-wsgi.rst @@ -150,3 +150,13 @@ events from the various neutron agents. Signs that there are too few can be agent heartbeats arriving late, nova vif bindings timing out on the hypervisors, or rpc message timeout exceptions in agent logs (for example, "broken pipe" errors). + +There is also the rpc_state_report_workers option, which determines +the number fo RPC worker processes dedicated to process state reports +from the various agents. This may be increased to resolve frequent delay +in processing agents heartbeats. + +.. note:: + If OVN ML2 plugin is used without any additional agents, neutron requires + no worker for RPC message processing. Set both rpc_workers and + rpc_state_report_workers to 0, to disable RPC workers. diff --git a/neutron/conf/service.py b/neutron/conf/service.py index 1c2be2b397d..6dcbe77d9b3 100644 --- a/neutron/conf/service.py +++ b/neutron/conf/service.py @@ -31,7 +31,8 @@ SERVICE_OPTS = [ cfg.IntOpt('rpc_workers', help=_('Number of RPC worker processes for service. ' 'If not specified, the default is equal to half the ' - 'number of API workers.')), + 'number of API workers. If set to 0, no RPC worker ' + 'is launched.')), cfg.IntOpt('rpc_state_report_workers', default=1, help=_('Number of RPC worker processes dedicated to the state ' diff --git a/neutron/service.py b/neutron/service.py index 11981e138b6..784366036ff 100644 --- a/neutron/service.py +++ b/neutron/service.py @@ -177,7 +177,7 @@ def _get_rpc_workers(plugin=None): if workers is None: # By default, half as many rpc workers as api workers workers = int(_get_api_workers() / 2) - workers = max(workers, 1) + workers = max(workers, 1) # If workers > 0 then start_rpc_listeners would be called in a # subprocess and we cannot simply catch the NotImplementedError. It is @@ -191,9 +191,15 @@ def _get_rpc_workers(plugin=None): workers) raise NotImplementedError() - # passing service plugins only, because core plugin is among them - rpc_workers = [RpcWorker(service_plugins, - worker_process_count=workers)] + rpc_workers = [] + + if workers > 0: + # passing service plugins only, because core plugin is among them + rpc_workers.append( + RpcWorker(service_plugins, worker_process_count=workers)) + else: + LOG.warning('No rpc workers are launched. Make sure no agent is used ' + 'in this deployment.') if (cfg.CONF.rpc_state_report_workers > 0 and plugin.rpc_state_report_workers_supported()): diff --git a/neutron/tests/unit/test_service.py b/neutron/tests/unit/test_service.py index 3c6c36f1829..3979018d67a 100644 --- a/neutron/tests/unit/test_service.py +++ b/neutron/tests/unit/test_service.py @@ -54,12 +54,15 @@ class TestRunRpcWorkers(base.BaseTestCase): with mock.patch('neutron.service.RpcReportsWorker'): service._get_rpc_workers(plugin=mock.Mock()) init_call = mock_rpc_worker.call_args - expected_call = mock.call( - mock.ANY, worker_process_count=expected_passed_value) - self.assertEqual(expected_call, init_call) + if expected_passed_value > 0: + expected_call = mock.call( + mock.ANY, worker_process_count=expected_passed_value) + self.assertEqual(expected_call, init_call) + else: + mock_rpc_worker.assert_not_called() def test_rpc_workers_zero(self): - self._test_rpc_workers(0, 1) + self._test_rpc_workers(0, 0) def test_rpc_workers_default_api_workers_default(self): workers = max(int(self.worker_count / 2), 1) diff --git a/releasenotes/notes/bug-2052484-9a80c1d035349879.yaml b/releasenotes/notes/bug-2052484-9a80c1d035349879.yaml new file mode 100644 index 00000000000..e2fc5362feb --- /dev/null +++ b/releasenotes/notes/bug-2052484-9a80c1d035349879.yaml @@ -0,0 +1,16 @@ +--- +upgrade: + - | + Now setting ``[DEFAULT] rpc_workers = 0`` completely disables rpc workers. + In a deployment with additional agents, like the dhcp-agent, this option + should be set to a positive value. Note that all notifications from + neutron-server to agents were disabled when ``[DEFAULT] rpc_workers = 0`` + is set in 22.0.0 release, so this was the requiremenet actually added in + that release. + +fixes: + - | + [`bug 2052484 `_] + Now setting ``[DEFAULT] rpc_workers = 0`` completely disables rpc workers. + Previously one rpc worker was launched even though ``0`` is specifically + requested.