Merge "Not allow overcommit ratios to be negative"

This commit is contained in:
Jenkins
2016-10-19 11:02:50 +00:00
committed by Gerrit Code Review
3 changed files with 29 additions and 0 deletions

View File

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

View File

@@ -14,6 +14,7 @@ import copy
import datetime import datetime
import mock import mock
from oslo_config import cfg
from oslo_utils import timeutils from oslo_utils import timeutils
from oslo_utils import units from oslo_utils import units
@@ -38,6 +39,7 @@ from nova.tests import uuidsentinel as uuids
_HOSTNAME = 'fake-host' _HOSTNAME = 'fake-host'
_NODENAME = 'fake-node' _NODENAME = 'fake-node'
CONF = cfg.CONF
_VIRT_DRIVER_AVAIL_RESOURCES = { _VIRT_DRIVER_AVAIL_RESOURCES = {
'vcpus': 4, 'vcpus': 4,
@@ -2273,3 +2275,20 @@ class TestIsTrackableMigration(test.NoDBTestCase):
mig.migration_type = mig_type mig.migration_type = mig_type
self.assertFalse(resource_tracker._is_trackable_migration(mig)) 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.