Merge "Disallow CONF.compute.max_disk_devices_to_attach = 0" into stable/train

This commit is contained in:
Zuul 2021-02-23 19:34:57 +00:00 committed by Gerrit Code Review
commit e39e622cb0
3 changed files with 19 additions and 1 deletions

View File

@ -1330,6 +1330,13 @@ class ComputeManager(manager.Manager):
eventlet.semaphore.BoundedSemaphore( eventlet.semaphore.BoundedSemaphore(
CONF.compute.max_concurrent_disk_ops) CONF.compute.max_concurrent_disk_ops)
if CONF.compute.max_disk_devices_to_attach == 0:
msg = _('[compute]max_disk_devices_to_attach has been set to 0, '
'which will prevent instances from being able to boot. '
'Set -1 for unlimited or set >= 1 to limit the maximum '
'number of disk devices.')
raise exception.InvalidConfiguration(msg)
self.driver.init_host(host=self.host) self.driver.init_host(host=self.host)
context = nova.context.get_admin_context() context = nova.context.get_admin_context()
instances = objects.InstanceList.get_by_host( instances = objects.InstanceList.get_by_host(

View File

@ -946,10 +946,16 @@ on compute host B.
The configured maximum is not enforced on shelved offloaded servers, as they The configured maximum is not enforced on shelved offloaded servers, as they
have no compute host. have no compute host.
.. warning:: If this option is set to 0, the ``nova-compute`` service will fail
to start, as 0 disk devices is an invalid configuration that would
prevent instances from being able to boot.
Possible values: Possible values:
* -1 means unlimited * -1 means unlimited
* Any integer >= 0 represents the maximum allowed * Any integer >= 1 represents the maximum allowed. A value of 0 will cause the
``nova-compute`` service to fail to start, as 0 disk devices is an invalid
configuration that would prevent instances from being able to boot.
"""), """),
] ]

View File

@ -963,6 +963,11 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase,
mock_error_interrupted.assert_called_once_with( mock_error_interrupted.assert_called_once_with(
self.context, {active_instance.uuid, evacuating_instance.uuid}) self.context, {active_instance.uuid, evacuating_instance.uuid})
def test_init_host_disk_devices_configuration_failure(self):
self.flags(max_disk_devices_to_attach=0, group='compute')
self.assertRaises(exception.InvalidConfiguration,
self.compute.init_host)
@mock.patch.object(objects.InstanceList, 'get_by_host', @mock.patch.object(objects.InstanceList, 'get_by_host',
new=mock.Mock()) new=mock.Mock())
@mock.patch('nova.compute.manager.ComputeManager.' @mock.patch('nova.compute.manager.ComputeManager.'