Prevent instance disk overcommit against itself
The CPU/RAM filters currently prevent scheduling an instance that is larger than the hypervisor total resource size. This does the same for the disk filter. Previously it was possible to schedule a 10Gb instance on an 8Gb host if the overcommit ratio permitted. Change-Id: Ia9963434bfb8845903b4e138545660a3827418e9
This commit is contained in:
@@ -46,14 +46,28 @@ class TestDiskFilter(test.NoDBTestCase):
|
||||
filt_cls = disk_filter.DiskFilter()
|
||||
spec_obj = objects.RequestSpec(
|
||||
flavor=objects.Flavor(
|
||||
root_gb=100, ephemeral_gb=18, swap=1024))
|
||||
# 1GB used... so 119GB allowed...
|
||||
root_gb=3, ephemeral_gb=3, swap=1024))
|
||||
# Only 1Gb left, but with 10x overprovision a 7Gb instance should
|
||||
# still fit. Schedule will succeed.
|
||||
host = fakes.FakeHostState('host1', 'node1',
|
||||
{'free_disk_mb': 11 * 1024, 'total_usable_disk_gb': 12,
|
||||
{'free_disk_mb': 1 * 1024, 'total_usable_disk_gb': 12,
|
||||
'disk_allocation_ratio': 10.0})
|
||||
self.assertTrue(filt_cls.host_passes(host, spec_obj))
|
||||
self.assertEqual(12 * 10.0, host.limits['disk_gb'])
|
||||
|
||||
def test_disk_filter_oversubscribe_single_instance_fails(self):
|
||||
filt_cls = disk_filter.DiskFilter()
|
||||
spec_obj = objects.RequestSpec(
|
||||
flavor=objects.Flavor(
|
||||
root_gb=10, ephemeral_gb=2, swap=1024))
|
||||
# According to the allocation ratio, This host has 119 Gb left,
|
||||
# but it doesn't matter because the requested instance is
|
||||
# bigger than the whole drive. Schedule will fail.
|
||||
host = fakes.FakeHostState('host1', 'node1',
|
||||
{'free_disk_mb': 11 * 1024, 'total_usable_disk_gb': 12,
|
||||
'disk_allocation_ratio': 10.0})
|
||||
self.assertFalse(filt_cls.host_passes(host, spec_obj))
|
||||
|
||||
def test_disk_filter_oversubscribe_fail(self):
|
||||
filt_cls = disk_filter.DiskFilter()
|
||||
spec_obj = objects.RequestSpec(
|
||||
@@ -74,7 +88,7 @@ class TestDiskFilter(test.NoDBTestCase):
|
||||
root_gb=1, ephemeral_gb=1, swap=1024))
|
||||
host = fakes.FakeHostState('host1', 'node1',
|
||||
{'free_disk_mb': 3 * 1024,
|
||||
'total_usable_disk_gb': 1,
|
||||
'total_usable_disk_gb': 4,
|
||||
'disk_allocation_ratio': 1.0})
|
||||
agg_mock.return_value = set(['XXX'])
|
||||
self.assertTrue(filt_cls.host_passes(host, spec_obj))
|
||||
@@ -89,7 +103,7 @@ class TestDiskFilter(test.NoDBTestCase):
|
||||
root_gb=2, ephemeral_gb=1, swap=1024))
|
||||
host = fakes.FakeHostState('host1', 'node1',
|
||||
{'free_disk_mb': 3 * 1024,
|
||||
'total_usable_disk_gb': 1,
|
||||
'total_usable_disk_gb': 4,
|
||||
'disk_allocation_ratio': 1.0})
|
||||
# Uses global conf.
|
||||
agg_mock.return_value = set([])
|
||||
|
||||
@@ -138,6 +138,7 @@ class CachingSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
||||
host_state.free_ram_mb = 50000
|
||||
host_state.total_usable_ram_mb = 50000
|
||||
host_state.free_disk_mb = 4096
|
||||
host_state.total_usable_disk_gb = 4
|
||||
host_state.service = {
|
||||
"disabled": False,
|
||||
"updated_at": timeutils.utcnow(),
|
||||
|
||||
Reference in New Issue
Block a user