Not allow overcommit ratios to be negative

Currently the three overcommit ratios: ram_allocation_ratio,
cpu_allocation_ratio, and disk_allocation_ratio can be set to negative values.
It's up to the scheduler filters to impose the checks on these ratios.

It makes more sense to make sure these 3 ratios are not negative when
nova-compute is started.  If any of these ratios is negative then nova-compute
service will fail to start.

Closes-Bug: #1604116
Change-Id: Ic960e319b59910c0178e81259b2e35435f2db592
This commit is contained in:
Vu Tran 2016-08-29 14:05:25 -04:00
parent bc344458e7
commit fcf2a644fb
3 changed files with 29 additions and 0 deletions

View File

@ -189,6 +189,7 @@ Possible values
allocation_ratio_opts = [
cfg.FloatOpt('cpu_allocation_ratio',
default=0.0,
min=0.0,
help="""
This option helps you specify virtual CPU to physical CPU allocation
ratio which affects all CPU filters.
@ -208,6 +209,7 @@ and defaulted to 16.0'.
"""),
cfg.FloatOpt('ram_allocation_ratio',
default=0.0,
min=0.0,
help="""
This option helps you specify virtual RAM to physical RAM
allocation ratio which affects all RAM filters.
@ -227,6 +229,7 @@ defaulted to 1.5.
"""),
cfg.FloatOpt('disk_allocation_ratio',
default=0.0,
min=0.0,
help="""
This option helps you specify virtual disk to physical disk
allocation ratio used by the disk_filter.py script to determine if

View File

@ -14,6 +14,7 @@ import copy
import datetime
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import units
@ -38,6 +39,7 @@ from nova.tests import uuidsentinel as uuids
_HOSTNAME = 'fake-host'
_NODENAME = 'fake-node'
CONF = cfg.CONF
_VIRT_DRIVER_AVAIL_RESOURCES = {
'vcpus': 4,
@ -2270,3 +2272,20 @@ class TestIsTrackableMigration(test.NoDBTestCase):
mig.migration_type = mig_type
self.assertFalse(resource_tracker._is_trackable_migration(mig))
class OverCommitTestCase(BaseTestCase):
def test_cpu_allocation_ratio_none_negative(self):
self.assertRaises(ValueError,
CONF.set_default, 'cpu_allocation_ratio', -1.0,
enforce_type=True)
def test_ram_allocation_ratio_none_negative(self):
self.assertRaises(ValueError,
CONF.set_default, 'ram_allocation_ratio', -1.0,
enforce_type=True)
def test_disk_allocation_ratio_none_negative(self):
self.assertRaises(ValueError,
CONF.set_default, 'disk_allocation_ratio', -1.0,
enforce_type=True)

View File

@ -0,0 +1,7 @@
---
upgrade:
- The three configuration options ``cpu_allocation_ratio``,
``ram_allocation_ratio`` and ``disk_allocation_ratio`` for
the nova compute are now checked against negative values.
If any of these three options is set to negative value
then nova compute service will fail to start.