summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-02-22 20:47:36 +0000
committerGerrit Code Review <review@openstack.org>2021-02-22 20:47:36 +0000
commitd814d13f4ac52282a6faba1918f95d3ea9219ef2 (patch)
tree475564f49031d76ad01125d247c2b1d973b4a38b
parent9c97bfd48193f75fac5761e54a34e2507b62df38 (diff)
parent4ad7e5e2630542bce4cfa53adafd1da299adb0f6 (diff)
downloadnova-d814d13f4ac52282a6faba1918f95d3ea9219ef2.tar.gz
Merge "Disallow CONF.compute.max_disk_devices_to_attach = 0" into stable/ussuri
-rw-r--r--nova/compute/manager.py7
-rw-r--r--nova/conf/compute.py8
-rw-r--r--nova/tests/unit/compute/test_compute_mgr.py5
3 files changed, 19 insertions, 1 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index e34064ea4d..036c850f20 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1394,6 +1394,13 @@ class ComputeManager(manager.Manager):
eventlet.semaphore.BoundedSemaphore(
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)
context = nova.context.get_admin_context()
instances = objects.InstanceList.get_by_host(
diff --git a/nova/conf/compute.py b/nova/conf/compute.py
index 4656ac0df4..8faddc721c 100644
--- a/nova/conf/compute.py
+++ b/nova/conf/compute.py
@@ -949,10 +949,16 @@ on compute host B.
The configured maximum is not enforced on shelved offloaded servers, as they
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:
* -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.
"""),
]
diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py
index 86a30c9076..ee39a6491a 100644
--- a/nova/tests/unit/compute/test_compute_mgr.py
+++ b/nova/tests/unit/compute/test_compute_mgr.py
@@ -1078,6 +1078,11 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase,
"time this service is starting on this host, then you can ignore "
"this warning.", 'fake-node1')
+ 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',
new=mock.Mock())
@mock.patch('nova.compute.manager.ComputeManager.'