Skip to content

Commit a98a145

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Disallow CONF.compute.max_disk_devices_to_attach = 0" into stable/victoria
2 parents e9c60dc + 8e12b81 commit a98a145

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

nova/compute/manager.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,13 @@ def init_host(self):
14111411
eventlet.semaphore.BoundedSemaphore(
14121412
CONF.compute.max_concurrent_disk_ops)
14131413

1414+
if CONF.compute.max_disk_devices_to_attach == 0:
1415+
msg = _('[compute]max_disk_devices_to_attach has been set to 0, '
1416+
'which will prevent instances from being able to boot. '
1417+
'Set -1 for unlimited or set >= 1 to limit the maximum '
1418+
'number of disk devices.')
1419+
raise exception.InvalidConfiguration(msg)
1420+
14141421
self.driver.init_host(host=self.host)
14151422
context = nova.context.get_admin_context()
14161423
instances = objects.InstanceList.get_by_host(

nova/conf/compute.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,10 +962,16 @@
962962
The configured maximum is not enforced on shelved offloaded servers, as they
963963
have no compute host.
964964
965+
.. warning:: If this option is set to 0, the ``nova-compute`` service will fail
966+
to start, as 0 disk devices is an invalid configuration that would
967+
prevent instances from being able to boot.
968+
965969
Possible values:
966970
967971
* -1 means unlimited
968-
* Any integer >= 0 represents the maximum allowed
972+
* Any integer >= 1 represents the maximum allowed. A value of 0 will cause the
973+
``nova-compute`` service to fail to start, as 0 disk devices is an invalid
974+
configuration that would prevent instances from being able to boot.
969975
"""),
970976
cfg.StrOpt('provider_config_location',
971977
default='/etc/nova/provider_config/',

nova/tests/unit/compute/test_compute_mgr.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,11 @@ def test_get_nodes_node_not_found(
11111111
"time this service is starting on this host, then you can ignore "
11121112
"this warning.", 'fake-node1')
11131113

1114+
def test_init_host_disk_devices_configuration_failure(self):
1115+
self.flags(max_disk_devices_to_attach=0, group='compute')
1116+
self.assertRaises(exception.InvalidConfiguration,
1117+
self.compute.init_host)
1118+
11141119
@mock.patch.object(objects.InstanceList, 'get_by_host',
11151120
new=mock.Mock())
11161121
@mock.patch('nova.compute.manager.ComputeManager.'

0 commit comments

Comments
 (0)