Merge "filter: add per-aggregate filter to configure max_io_ops_per_host"

This commit is contained in:
Jenkins
2014-08-26 10:31:36 +00:00
committed by Gerrit Code Review
3 changed files with 63 additions and 1 deletions

View File

@@ -15,8 +15,10 @@
from oslo.config import cfg
from nova.i18n import _LW
from nova.openstack.common import log as logging
from nova.scheduler import filters
from nova.scheduler.filters import utils
LOG = logging.getLogger(__name__)
@@ -34,12 +36,16 @@ CONF.register_opt(max_io_ops_per_host_opt)
class IoOpsFilter(filters.BaseHostFilter):
"""Filter out hosts with too many concurrent I/O operations."""
def _get_max_io_ops_per_host(self, host_state, filter_properties):
return CONF.max_io_ops_per_host
def host_passes(self, host_state, filter_properties):
"""Use information about current vm and task states collected from
compute node statistics to decide whether to filter.
"""
num_io_ops = host_state.num_io_ops
max_io_ops = CONF.max_io_ops_per_host
max_io_ops = self._get_max_io_ops_per_host(
host_state, filter_properties)
passes = num_io_ops < max_io_ops
if not passes:
LOG.debug("%(host_state)s fails I/O ops check: Max IOs per host "
@@ -47,3 +53,27 @@ class IoOpsFilter(filters.BaseHostFilter):
{'host_state': host_state,
'max_io_ops': max_io_ops})
return passes
class AggregateIoOpsFilter(IoOpsFilter):
"""AggregateIoOpsFilter with per-aggregate the max io operations.
Fall back to global max_io_ops_per_host if no per-aggregate setting found.
"""
def _get_max_io_ops_per_host(self, host_state, filter_properties):
# TODO(uni): DB query in filter is a performance hit, especially for
# system with lots of hosts. Will need a general solution here to fix
# all filters with aggregate DB call things.
aggregate_vals = utils.aggregate_values_from_db(
filter_properties['context'],
host_state.host,
'max_io_ops_per_host')
try:
value = utils.validate_num_values(
aggregate_vals, CONF.max_io_ops_per_host, cast_to=int)
except ValueError as e:
LOG.warn(_LW("Could not decode max_io_ops_per_host: '%s'"), e)
value = CONF.max_io_ops_per_host
return value