summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Elliott <brian.elliott@rackspace.com>2012-09-28 02:54:51 +0000
committerBrian Elliott <brian.elliott@rackspace.com>2012-09-28 06:23:47 +0000
commit2c50abe05af33d7150cbeec40bcdf31a626c0844 (patch)
treed88c22dee340302669ff94d460ee0ad125074ba2
parent64702669c879dbc5cf27712ef8fadb9fd043664d (diff)
downloadnova-2c50abe05af33d7150cbeec40bcdf31a626c0844.tar.gz
nova-2c50abe05af33d7150cbeec40bcdf31a626c0844.tar.xz
nova-2c50abe05af33d7150cbeec40bcdf31a626c0844.zip
Max I/O ops per host scheduler filter
Provide ability to filter hosts based on the number of concurrent build, resize, and image snapshot operations in progress. FLAGS.max_io_ops_per_host is used to control the number of concurrent permitted operations. Change-Id: I77feca00a6b6b248de8423cef7fb8da2cf704930
-rw-r--r--nova/scheduler/filters/io_ops_filter.py44
-rw-r--r--nova/tests/scheduler/test_host_filters.py16
2 files changed, 60 insertions, 0 deletions
diff --git a/nova/scheduler/filters/io_ops_filter.py b/nova/scheduler/filters/io_ops_filter.py
new file mode 100644
index 000000000..c2e0205a3
--- /dev/null
+++ b/nova/scheduler/filters/io_ops_filter.py
@@ -0,0 +1,44 @@
+# Copyright (c) 2012 OpenStack, LLC.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from nova import flags
+from nova.openstack.common import cfg
+from nova.openstack.common import log as logging
+from nova.scheduler import filters
+
+LOG = logging.getLogger(__name__)
+
+max_io_ops_per_host_opt = cfg.IntOpt("max_io_ops_per_host",
+ default=8,
+ help="Ignore hosts that have too many builds/resizes/snaps/migrations")
+
+FLAGS = flags.FLAGS
+FLAGS.register_opt(max_io_ops_per_host_opt)
+
+
+class IoOpsFilter(filters.BaseHostFilter):
+ """Filter out hosts with too many concurrent I/O operations"""
+
+ 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 = FLAGS.max_io_ops_per_host
+ passes = num_io_ops < max_io_ops
+ if not passes:
+ LOG.debug(_("%(host_state)s fails I/O ops check: Max IOs per host "
+ "is set to %(max_io_ops)s"), locals())
+ return passes
diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py
index 42d43a197..b1e1ec897 100644
--- a/nova/tests/scheduler/test_host_filters.py
+++ b/nova/tests/scheduler/test_host_filters.py
@@ -1278,3 +1278,19 @@ class HostFiltersTestCase(test.TestCase):
retry = dict(num_attempts=1, hosts=['host3', 'host1'])
filter_properties = dict(retry=retry)
self.assertFalse(filt_cls.host_passes(host, filter_properties))
+
+ def test_filter_num_iops_passes(self):
+ self.flags(max_io_ops_per_host=8)
+ filt_cls = self.class_map['IoOpsFilter']()
+ host = fakes.FakeHostState('host1', 'compute',
+ {'num_io_ops': 7})
+ filter_properties = {}
+ self.assertTrue(filt_cls.host_passes(host, filter_properties))
+
+ def test_filter_num_iops_fails(self):
+ self.flags(max_io_ops_per_host=8)
+ filt_cls = self.class_map['IoOpsFilter']()
+ host = fakes.FakeHostState('host1', 'compute',
+ {'num_io_ops': 8})
+ filter_properties = {}
+ self.assertFalse(filt_cls.host_passes(host, filter_properties))