From 21bb17499f83ec67aaadd8affb6d2899e567d151 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Mon, 18 Sep 2017 13:14:06 +0300 Subject: [PATCH] hyperv: report disk_available_least field Reporting the disk_available_least field can help in making sure the scheduler doesn't pick a host that cannot fit a specific flavor's disk. The reported local_gb_used is calculated based on the instances spawned by nova on a certain compute node, and might not reflect the actual reality, especially on shared storage scenarios. Change-Id: I20992acef119f11f6584094438043a760fc4a287 Closes-Bug: #1717892 --- nova/tests/unit/virt/hyperv/test_hostops.py | 1 + nova/virt/hyperv/hostops.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/nova/tests/unit/virt/hyperv/test_hostops.py b/nova/tests/unit/virt/hyperv/test_hostops.py index 378d252594b6..73bb5d8955fe 100644 --- a/nova/tests/unit/virt/hyperv/test_hostops.py +++ b/nova/tests/unit/virt/hyperv/test_hostops.py @@ -197,6 +197,7 @@ class HostOpsTestCase(test_base.HyperVBaseTestCase): 'memory_mb_used': mock.sentinel.MEMORY_MB_USED, 'local_gb': mock.sentinel.LOCAL_GB, 'local_gb_used': mock.sentinel.LOCAL_GB_USED, + 'disk_available_least': mock.sentinel.LOCAL_GB_FREE, 'vcpus': self.FAKE_NUM_CPUS, 'vcpus_used': 0, 'hypervisor_type': 'hyperv', diff --git a/nova/virt/hyperv/hostops.py b/nova/virt/hyperv/hostops.py index ca5fe19a3e1c..0ab1c05a7b0a 100644 --- a/nova/virt/hyperv/hostops.py +++ b/nova/virt/hyperv/hostops.py @@ -158,11 +158,17 @@ class HostOps(object): cpu_topology['cores'] * cpu_topology['threads']) + # NOTE(claudiub): free_hdd_gb only refers to the currently free + # physical storage, it doesn't take into consideration the virtual + # sizes of the VMs' dynamic disks. This means that the VMs' disks can + # expand beyond the free_hdd_gb's value, and instances will still be + # scheduled to this compute node. dic = {'vcpus': vcpus, 'memory_mb': total_mem_mb, 'memory_mb_used': used_mem_mb, 'local_gb': total_hdd_gb, 'local_gb_used': used_hdd_gb, + 'disk_available_least': free_hdd_gb, 'hypervisor_type': "hyperv", 'hypervisor_version': self._get_hypervisor_version(), 'hypervisor_hostname': platform.node(),