Set minumum boundary for workers

api_workers=0 does not disable api workers but neutron-server still
launches one api worker. Rejecting 0 helps user notice that the value
they request in config files is not honored.

Also the other rpc workers options disable the corresponding workers
completely by setting these options to 0, so setting negative values
work but does not bring any special benefit.

Change-Id: Iac16b241c71ac1068c6fbea3cc792b74bfc66c03
This commit is contained in:
Takashi Kajinami 2024-02-07 02:22:27 +09:00
parent b38f72b212
commit 78e8f1dca0
3 changed files with 19 additions and 4 deletions

View File

@ -24,19 +24,23 @@ SERVICE_OPTS = [
default=40,
help=_('Seconds between running periodic tasks.')),
cfg.IntOpt('api_workers',
min=1,
help=_('Number of separate API worker processes for service. '
'If not specified, the default is equal to the number '
'of CPUs available for best performance, capped by '
'potential RAM usage.')),
cfg.IntOpt('rpc_workers',
min=0,
help=_('Number of RPC worker processes for service. '
'If not specified, the default is equal to half the '
'number of API workers. If set to 0, no RPC worker '
'is launched.')),
cfg.IntOpt('rpc_state_report_workers',
default=1,
min=0,
help=_('Number of RPC worker processes dedicated to the state '
'reports queue.')),
'reports queue. If set to 0, no dedicated RPC worker '
'for state reports queue is launched.')),
cfg.IntOpt('periodic_fuzzy_delay',
default=5,
help=_('Range of seconds to randomly delay when starting the '

View File

@ -92,8 +92,8 @@ class TestRunWsgiApp(base.BaseTestCase):
workers=expected_passed_value)
self.assertEqual(expected_call, start_call)
def test_api_workers_zero(self):
self._test_api_workers(0, 0)
def test_api_workers_one(self):
self._test_api_workers(1, 1)
def test_api_workers_default(self):
self._test_api_workers(None, self.worker_count)
@ -102,7 +102,7 @@ class TestRunWsgiApp(base.BaseTestCase):
self._test_api_workers(42, 42)
def test_start_all_workers(self):
cfg.CONF.set_override('api_workers', 0)
cfg.CONF.set_override('api_workers', 1)
mock.patch.object(service, '_get_rpc_workers').start()
mock.patch.object(service, '_get_plugins_workers').start()
mock.patch.object(service, '_start_workers').start()

View File

@ -0,0 +1,11 @@
---
upgrade:
- |
The ``[DEFAULT] api_workers`` option no longer accepts 0 or negative
values. Previously 0 or a negative value was translated to 1 and
neutron-server launched 1 api worker.
- |
The ``[DEFAULT] rpc_workers`` option and
the ``[DEFAULT] rpc_state_report_workers`` option no longer accept negative
values. To disable these workers, set these options to 0.