diff options
author | Yikun Jiang <yikunkero@gmail.com> | 2018-09-15 11:31:41 +0800 |
---|---|---|
committer | Matt Riedemann <mriedem.os@gmail.com> | 2018-11-30 15:32:06 -0500 |
commit | 08f3ae960623c94bdd997cacb3e81f04b4bbba69 (patch) | |
tree | 5803a053e6d1def021f630a849d322639d31c31a /nova/virt/powervm | |
parent | 212eff600ab6f016ed696a8d4bd884d572db8990 (diff) | |
download | nova-08f3ae960623c94bdd997cacb3e81f04b4bbba69.tar.gz |
Use new ``initial_xxx_allocation_ratio`` CONF
This patch adds new ``initial_xxx_allocation_ratio`` CONF options
and modifies the resource tracker's initial compute node creation to
use these values.
During the update_available_resource periodic task, the allocation
ratios reported to inventory for VCPU, MEMORY_MB and DISK_GB will
be based on:
* If CONF.*_allocation_ratio is set, use it. This overrides everything
including externally set allocation ratios via the placement API.
* If reporting inventory for the first time, the
CONF.initial_*_allocation_ratio value is used.
* For everything else, the inventory reported remains unchanged which
allows operators to set the allocation ratios on the inventory records
in placement directly without worrying about nova-compute overwriting
those changes.
As a result, several TODOs are removed from the virt drivers that
implement the update_provider_tree interface and a TODO in the resource
tracker about unset-ing allocation ratios to get back to initial values.
Change-Id: I14a310b20bd9892e7b34464e6baad49bf5928ece
blueprint: initial-allocation-ratios
Diffstat (limited to 'nova/virt/powervm')
-rw-r--r-- | nova/virt/powervm/driver.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/nova/virt/powervm/driver.py b/nova/virt/powervm/driver.py index a153257ee7..21a6a979ab 100644 --- a/nova/virt/powervm/driver.py +++ b/nova/virt/powervm/driver.py @@ -191,35 +191,34 @@ class PowerVMDriver(driver.ComputeDriver): # update_available_resource flow. data = self._get_available_resource() - # TODO(efried): Fix these to reflect something like reality - # For now, duplicate the logic the resource tracker uses via - # update_compute_node when get_inventory/update_provider_tree is not - # implemented. - cpu_alloc_ratio = CONF.cpu_allocation_ratio or 16.0 + # NOTE(yikun): If the inv record does not exists, the allocation_ratio + # will use the CONF.xxx_allocation_ratio value if xxx_allocation_ratio + # is set, and fallback to use the initial_xxx_allocation_ratio + # otherwise. + inv = provider_tree.data(nodename).inventory + ratios = self._get_allocation_ratios(inv) cpu_reserved = CONF.reserved_host_cpus - mem_alloc_ratio = CONF.ram_allocation_ratio or 1.5 mem_reserved = CONF.reserved_host_memory_mb - disk_alloc_ratio = CONF.disk_allocation_ratio or 1.0 disk_reserved = self._get_reserved_host_disk_gb_from_config() inventory = { rc_fields.ResourceClass.VCPU: { 'total': data['vcpus'], 'max_unit': data['vcpus'], - 'allocation_ratio': cpu_alloc_ratio, + 'allocation_ratio': ratios[rc_fields.ResourceClass.VCPU], 'reserved': cpu_reserved, }, rc_fields.ResourceClass.MEMORY_MB: { 'total': data['memory_mb'], 'max_unit': data['memory_mb'], - 'allocation_ratio': mem_alloc_ratio, + 'allocation_ratio': ratios[rc_fields.ResourceClass.MEMORY_MB], 'reserved': mem_reserved, }, rc_fields.ResourceClass.DISK_GB: { # TODO(efried): Proper DISK_GB sharing when SSP driver in play 'total': int(data['local_gb']), 'max_unit': int(data['local_gb']), - 'allocation_ratio': disk_alloc_ratio, + 'allocation_ratio': ratios[rc_fields.ResourceClass.DISK_GB], 'reserved': disk_reserved, }, } |