Calculate stopped instance's disk sizes for disk_available_least

disk_available_least is a free disk size information of hypervisors.
This is calculated by the following fomula:

disk_available_least = <free disk size> - <Total gap between virtual
disk size and actual disk size for all instances>

But stopped instance's virtual disk sizes were not calculated
after merging following patch in Juno cycle:
https://review.openstack.org/#/c/105127

So disk_available_least might be larger than actual free disk size.
As a result, instances might be scheduled beyond the actual free
disk size if stopped instances were on a host.

This patch fix it.
Stopped instance's disks will be calculated after merging this patch.

Change-Id: I8abf6edfa80e3920539e4f6d4906c573f9543b91
Closes-Bug: #1693679
This commit is contained in:
Rikimaru Honjo 2017-05-26 14:04:44 +09:00
parent 351a5dcec5
commit 3342215034
2 changed files with 3 additions and 3 deletions

View File

@ -12527,7 +12527,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
result = drvr._get_disk_over_committed_size_total()
self.assertEqual(result, 10653532160)
mock_list.assert_called_once_with()
mock_list.assert_called_once_with(only_running=False)
self.assertEqual(2, mock_info.call_count)
filters = {'uuid': instance_uuids}
@ -12638,7 +12638,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
result = drvr._get_disk_over_committed_size_total()
self.assertEqual(42949672960, result)
mock_list.assert_called_once_with()
mock_list.assert_called_once_with(only_running=False)
self.assertEqual(5, get_disk_info.call_count)
filters = {'uuid': instance_uuids}
mock_get.assert_called_once_with(mock.ANY, filters, use_slave=True)

View File

@ -7171,7 +7171,7 @@ class LibvirtDriver(driver.ComputeDriver):
"""Return total over committed disk size for all instances."""
# Disk size that all instance uses : virtual_size - disk_size
disk_over_committed_size = 0
instance_domains = self._host.list_instance_domains()
instance_domains = self._host.list_instance_domains(only_running=False)
if not instance_domains:
return disk_over_committed_size