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.

Merging Changeset:
https://github.com/openstack/nova/commit/
08f3ae960623c94bdd997cacb3e81f04b4bbba69#
diff-46d49d172cae6b899c1be3628dede5d1

Change-Id: I29f6f1642a4c2855129d31bb333cc80020e4854b
This commit is contained in:
VedaAnnayappa 2019-07-26 02:29:10 -04:00 committed by VedaAnnayappa
parent 5de7a5ebdc
commit 9ee5a973d7
2 changed files with 15 additions and 11 deletions

View File

@ -1668,7 +1668,7 @@ class TestPowerVMDriver(test.NoDBTestCase):
def test_update_provider_tree_complex_ptree(self):
# Overrides inventory already on the provider; leaves other providers
# and aggregates/traits alone.
with self._update_provider_tree() as (ptree, _):
with self._update_provider_tree() as (ptree, exp_inv):
ptree.update_inventory('compute_host', {
# these should get blown away
'VCPU': {
@ -1689,6 +1689,11 @@ class TestPowerVMDriver(test.NoDBTestCase):
'for': 'ssp'})
ptree.update_aggregates('ssp', [uuids.ss_agg])
ptree.new_child('sriov', 'compute_host', uuid=uuids.sriov)
# Since CONF.cpu_allocation_ratio is not set and this is not
# the initial upt call (so CONF.initial_cpu_allocation_ratio would
# be used), the existing allocation ratio value from the tree is
# used.
exp_inv['VCPU']['allocation_ratio'] = 1.0
# Make sure the compute's agg and traits were left alone
cndata = ptree.data('compute_host')

View File

@ -1010,35 +1010,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 = {
orc.VCPU: {
'total': data['vcpus'],
'max_unit': data['vcpus'],
'allocation_ratio': cpu_alloc_ratio,
'allocation_ratio': ratios[orc.VCPU],
'reserved': cpu_reserved,
},
orc.MEMORY_MB: {
'total': data['memory_mb'],
'max_unit': data['memory_mb'],
'allocation_ratio': mem_alloc_ratio,
'allocation_ratio': ratios[orc.MEMORY_MB],
'reserved': mem_reserved,
},
orc.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[orc.DISK_GB],
'reserved': disk_reserved,
},
}