summaryrefslogtreecommitdiff
path: root/nova/scheduler
diff options
context:
space:
mode:
authorSylvain Bauza <sbauza@redhat.com>2015-08-25 14:45:05 +0200
committerSylvain Bauza <sbauza@redhat.com>2015-08-31 15:21:23 +0200
commit1c195210eb6eea1e6bfc77f8cef335c53b5d6b31 (patch)
treeb969904d9834f14108c90c53f76bc93c90a682d3 /nova/scheduler
parentf4138f69cc88a576f188ce665b2ac699ae232ad3 (diff)
downloadnova-1c195210eb6eea1e6bfc77f8cef335c53b5d6b31.tar.gz
Update HostManager and filters to use ComputeNode ratios
Since the ComputeNode object provides a compatible facade for the Scheduler, we can get it from the HostManager and provide those fields up to the filters. As the HostManager is calling ComputeNodeList.get_all(), then the related HostStates will all have the scheduler nova.conf allocation ratios. Change-Id: I3bd28cd2069ada2f9b0d1fd9c05d12bb6f8f75d9 Partially-Implements: blueprint allocation-ratio-to-resource-tracker
Diffstat (limited to 'nova/scheduler')
-rw-r--r--nova/scheduler/filters/core_filter.py13
-rw-r--r--nova/scheduler/filters/numa_topology_filter.py10
-rw-r--r--nova/scheduler/filters/ram_filter.py13
-rw-r--r--nova/scheduler/host_manager.py8
-rw-r--r--nova/scheduler/ironic_host_manager.py5
5 files changed, 21 insertions, 28 deletions
diff --git a/nova/scheduler/filters/core_filter.py b/nova/scheduler/filters/core_filter.py
index 26f41070a4..1fed2c0340 100644
--- a/nova/scheduler/filters/core_filter.py
+++ b/nova/scheduler/filters/core_filter.py
@@ -15,7 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_config import cfg
from oslo_log import log as logging
from nova.i18n import _LW
@@ -24,12 +23,6 @@ from nova.scheduler.filters import utils
LOG = logging.getLogger(__name__)
-CONF = cfg.CONF
-
-# TODO(sbauza): Remove the import once all compute nodes are reporting the
-# allocation ratio to the HostState
-CONF.import_opt('cpu_allocation_ratio', 'nova.compute.resource_tracker')
-
class BaseCoreFilter(filters.BaseHostFilter):
@@ -84,7 +77,7 @@ class CoreFilter(BaseCoreFilter):
"""CoreFilter filters based on CPU core utilization."""
def _get_cpu_allocation_ratio(self, host_state, filter_properties):
- return CONF.cpu_allocation_ratio
+ return host_state.cpu_allocation_ratio
class AggregateCoreFilter(BaseCoreFilter):
@@ -99,9 +92,9 @@ class AggregateCoreFilter(BaseCoreFilter):
'cpu_allocation_ratio')
try:
ratio = utils.validate_num_values(
- aggregate_vals, CONF.cpu_allocation_ratio, cast_to=float)
+ aggregate_vals, host_state.cpu_allocation_ratio, cast_to=float)
except ValueError as e:
LOG.warning(_LW("Could not decode cpu_allocation_ratio: '%s'"), e)
- ratio = CONF.cpu_allocation_ratio
+ ratio = host_state.cpu_allocation_ratio
return ratio
diff --git a/nova/scheduler/filters/numa_topology_filter.py b/nova/scheduler/filters/numa_topology_filter.py
index 938bf112cc..655f21b969 100644
--- a/nova/scheduler/filters/numa_topology_filter.py
+++ b/nova/scheduler/filters/numa_topology_filter.py
@@ -10,23 +10,17 @@
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_config import cfg
-
from nova import objects
from nova.scheduler import filters
from nova.virt import hardware
-CONF = cfg.CONF
-CONF.import_opt('cpu_allocation_ratio', 'nova.scheduler.filters.core_filter')
-CONF.import_opt('ram_allocation_ratio', 'nova.scheduler.filters.ram_filter')
-
class NUMATopologyFilter(filters.BaseHostFilter):
"""Filter on requested NUMA topology."""
def host_passes(self, host_state, filter_properties):
- ram_ratio = CONF.ram_allocation_ratio
- cpu_ratio = CONF.cpu_allocation_ratio
+ ram_ratio = host_state.ram_allocation_ratio
+ cpu_ratio = host_state.cpu_allocation_ratio
request_spec = filter_properties.get('request_spec', {})
instance = request_spec.get('instance_properties', {})
requested_topology = hardware.instance_topology_from_instance(instance)
diff --git a/nova/scheduler/filters/ram_filter.py b/nova/scheduler/filters/ram_filter.py
index 839dcee9e1..3e7fbf5074 100644
--- a/nova/scheduler/filters/ram_filter.py
+++ b/nova/scheduler/filters/ram_filter.py
@@ -14,7 +14,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-from oslo_config import cfg
from oslo_log import log as logging
from nova.i18n import _LW
@@ -23,12 +22,6 @@ from nova.scheduler.filters import utils
LOG = logging.getLogger(__name__)
-CONF = cfg.CONF
-
-# TODO(sbauza): Remove the import once all compute nodes are reporting the
-# allocation ratio to the HostState
-CONF.import_opt('ram_allocation_ratio', 'nova.compute.resource_tracker')
-
class BaseRamFilter(filters.BaseHostFilter):
@@ -76,7 +69,7 @@ class RamFilter(BaseRamFilter):
"""Ram Filter with over subscription flag."""
def _get_ram_allocation_ratio(self, host_state, filter_properties):
- return CONF.ram_allocation_ratio
+ return host_state.ram_allocation_ratio
class AggregateRamFilter(BaseRamFilter):
@@ -92,9 +85,9 @@ class AggregateRamFilter(BaseRamFilter):
try:
ratio = utils.validate_num_values(
- aggregate_vals, CONF.ram_allocation_ratio, cast_to=float)
+ aggregate_vals, host_state.ram_allocation_ratio, cast_to=float)
except ValueError as e:
LOG.warning(_LW("Could not decode ram_allocation_ratio: '%s'"), e)
- ratio = CONF.ram_allocation_ratio
+ ratio = host_state.ram_allocation_ratio
return ratio
diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py
index 6fe092db51..f55665a9ea 100644
--- a/nova/scheduler/host_manager.py
+++ b/nova/scheduler/host_manager.py
@@ -184,6 +184,10 @@ class HostState(object):
# Instances on this host
self.instances = {}
+ # Allocation ratios for this host
+ self.ram_allocation_ratio = None
+ self.cpu_allocation_ratio = None
+
self.updated = None
if compute:
self.update_from_compute_node(compute)
@@ -251,6 +255,10 @@ class HostState(object):
# update metrics
self.metrics = objects.MonitorMetricList.from_json(compute.metrics)
+ # update allocation ratios given by the ComputeNode object
+ self.cpu_allocation_ratio = compute.cpu_allocation_ratio
+ self.ram_allocation_ratio = compute.ram_allocation_ratio
+
@set_update_time_on_success
def consume_from_instance(self, instance):
"""Incrementally update host state from an instance."""
diff --git a/nova/scheduler/ironic_host_manager.py b/nova/scheduler/ironic_host_manager.py
index 3fde40cd6e..4b291908e6 100644
--- a/nova/scheduler/ironic_host_manager.py
+++ b/nova/scheduler/ironic_host_manager.py
@@ -81,6 +81,11 @@ class IronicNodeState(host_manager.HostState):
in compute.supported_hv_specs]
else:
self.supported_instances = []
+
+ # update allocation ratios given by the ComputeNode object
+ self.cpu_allocation_ratio = compute.cpu_allocation_ratio
+ self.ram_allocation_ratio = compute.ram_allocation_ratio
+
self.updated = compute.updated_at
@host_manager.set_update_time_on_success