Fix regression preventing reporting negative resources for overcommit
In Nova prior to Ocata, the scheduler computes available resources for a compute node, attempting to mirror the same calculation that happens locally. It does this to determine if a new instance should fit on the node. If overcommit is being used, some of these numbers can be negative. In change016b810f67
we changed the compute side to never report negative resources, which was an ironic- specific fix for nodes that are offline. That, however, has been corrected for ironic nodes in047da6498d
. Since the base change to the resource tracker has caused the scheduler and compute to do different math, we need to revert it to avoid the scheduler sending instances to nodes where it believes -NNN is the lower limit (with overcommit), but the node is reporting zero. This doesn't actually affect Ocata because of our use of the placement engine. However, this code is still in master and needs to be backported. This part of the change actually didn't even have a unit test, so this patch adds one to validate that the resource tracker will calculate and report negative resources. Conflicts: nova/compute/resource_tracker.py nova/tests/unit/compute/test_resource_tracker.py NOTE(mriedem): The conflict is due to change I80ba844a6e0fcea89f80aa253d57ac73092773ae not being in Ocata. Change-Id: I25ba6f7f4e4fab6db223368427d889d6b06a77e8 Closes-Bug: #1698383 (cherry picked from commit0ddf3ce011
)
This commit is contained in:
parent
fe32902926
commit
3284851437
|
@ -954,8 +954,6 @@ class ResourceTracker(object):
|
|||
|
||||
self.scheduler_client.reportclient.remove_deleted_instances(
|
||||
cn, self.tracked_instances.values())
|
||||
cn.free_ram_mb = max(0, cn.free_ram_mb)
|
||||
cn.free_disk_gb = max(0, cn.free_disk_gb)
|
||||
|
||||
def _find_orphaned_instances(self):
|
||||
"""Given the set of instances and migrations already account for
|
||||
|
|
|
@ -2170,6 +2170,26 @@ class TestUpdateUsageFromInstance(BaseTestCase):
|
|||
mock_update_usage.assert_called_once_with(
|
||||
self.rt._get_usage_dict(self.instance), _NODENAME, sign=-1)
|
||||
|
||||
def test_update_usage_from_instances_goes_negative(self):
|
||||
# NOTE(danms): The resource tracker _should_ report negative resources
|
||||
# for things like free_ram_mb if overcommit is being used. This test
|
||||
# ensures that we don't collapse negative values to zero.
|
||||
self.flags(reserved_host_memory_mb=2048)
|
||||
self.flags(reserved_host_disk_mb=(11 * 1024))
|
||||
cn = objects.ComputeNode(memory_mb=1024, local_gb=10)
|
||||
self.rt.compute_nodes['foo'] = cn
|
||||
|
||||
@mock.patch.object(self.sched_client_mock.reportclient,
|
||||
'remove_deleted_instances')
|
||||
@mock.patch.object(self.rt, '_update_usage_from_instance')
|
||||
def test(uufi, rdia):
|
||||
self.rt._update_usage_from_instances('ctxt', [], 'foo')
|
||||
|
||||
test()
|
||||
|
||||
self.assertEqual(-1024, cn.free_ram_mb)
|
||||
self.assertEqual(-1, cn.free_disk_gb)
|
||||
|
||||
|
||||
class TestInstanceInResizeState(test.NoDBTestCase):
|
||||
def test_active_suspending(self):
|
||||
|
|
Loading…
Reference in New Issue