diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-11-29 19:58:03 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-11-29 19:58:03 +0000 |
| commit | 8fa7f6353df36eae2b3ef9ea68563e3e67f875d2 (patch) | |
| tree | c2e2e16c8a7f9d7e443fe9011e414ac3775b7f2a /nova | |
| parent | d16e74ad2a8145e35aeed71e4adf49e9713ee5d4 (diff) | |
| parent | f87c2e8334306cb7ef78b64a4bf5949b73d87617 (diff) | |
| download | nova-8fa7f6353df36eae2b3ef9ea68563e3e67f875d2.tar.gz nova-8fa7f6353df36eae2b3ef9ea68563e3e67f875d2.tar.xz nova-8fa7f6353df36eae2b3ef9ea68563e3e67f875d2.zip | |
Merge "RetryFilter checks 'node' as well as 'host'"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/scheduler/filter_scheduler.py | 15 | ||||
| -rw-r--r-- | nova/scheduler/filters/retry_filter.py | 6 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_filter_scheduler.py | 15 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_host_filters.py | 14 |
4 files changed, 29 insertions, 21 deletions
diff --git a/nova/scheduler/filter_scheduler.py b/nova/scheduler/filter_scheduler.py index 03fd9cd1a..c18daa4cc 100644 --- a/nova/scheduler/filter_scheduler.py +++ b/nova/scheduler/filter_scheduler.py @@ -147,24 +147,25 @@ class FilterScheduler(driver.Scheduler): def _post_select_populate_filter_properties(self, filter_properties, host_state): - """Add additional information to the filter properties after a host has + """Add additional information to the filter properties after a node has been selected by the scheduling process. """ - # Add a retry entry for the selected compute host: - self._add_retry_host(filter_properties, host_state.host) + # Add a retry entry for the selected compute host and node: + self._add_retry_host(filter_properties, host_state.host, + host_state.nodename) self._add_oversubscription_policy(filter_properties, host_state) - def _add_retry_host(self, filter_properties, host): - """Add a retry entry for the selected compute host. In the event that + def _add_retry_host(self, filter_properties, host, node): + """Add a retry entry for the selected compute node. In the event that the request gets re-scheduled, this entry will signal that the given - host has already been tried. + node has already been tried. """ retry = filter_properties.get('retry', None) if not retry: return hosts = retry['hosts'] - hosts.append(host) + hosts.append((host, node)) def _add_oversubscription_policy(self, filter_properties, host_state): filter_properties['limits'] = host_state.limits diff --git a/nova/scheduler/filters/retry_filter.py b/nova/scheduler/filters/retry_filter.py index 6740ec099..108e4d206 100644 --- a/nova/scheduler/filters/retry_filter.py +++ b/nova/scheduler/filters/retry_filter.py @@ -20,12 +20,12 @@ LOG = logging.getLogger(__name__) class RetryFilter(filters.BaseHostFilter): - """Filter out hosts that have already been attempted for scheduling + """Filter out nodes that have already been attempted for scheduling purposes """ def host_passes(self, host_state, filter_properties): - """Skip hosts that have already been attempted""" + """Skip nodes that have already been attempted""" retry = filter_properties.get('retry', None) if not retry: # Re-scheduling is disabled @@ -33,7 +33,7 @@ class RetryFilter(filters.BaseHostFilter): return True hosts = retry.get('hosts', []) - host = host_state.host + host = (host_state.host, host_state.nodename) LOG.debug(_("Previously tried hosts: %(hosts)s. (host=%(host)s)") % locals()) diff --git a/nova/tests/scheduler/test_filter_scheduler.py b/nova/tests/scheduler/test_filter_scheduler.py index d44c79b72..673e64997 100644 --- a/nova/tests/scheduler/test_filter_scheduler.py +++ b/nova/tests/scheduler/test_filter_scheduler.py @@ -280,16 +280,17 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): retry = dict(num_attempts=1, hosts=[]) filter_properties = dict(retry=retry) host = "fakehost" + node = "fakenode" sched = fakes.FakeFilterScheduler() - sched._add_retry_host(filter_properties, host) + sched._add_retry_host(filter_properties, host, node) hosts = filter_properties['retry']['hosts'] self.assertEqual(1, len(hosts)) - self.assertEqual(host, hosts[0]) + self.assertEqual((host, node), hosts[0]) def test_post_select_populate(self): - """Test addition of certain filter props after a host is selected""" + """Test addition of certain filter props after a node is selected""" retry = {'hosts': [], 'num_attempts': 1} filter_properties = {'retry': retry} sched = fakes.FakeFilterScheduler() @@ -299,12 +300,13 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): sched._post_select_populate_filter_properties(filter_properties, host_state) - self.assertEqual('host', filter_properties['retry']['hosts'][0]) + self.assertEqual(('host', 'node'), + filter_properties['retry']['hosts'][0]) self.assertEqual({'vcpus': 5}, host_state.limits) def test_prep_resize_post_populates_retry(self): - """Prep resize should add a 'host' entry to the retry dict""" + """Prep resize should add a ('host', 'node') entry to the retry dict""" sched = fakes.FakeFilterScheduler() image = 'image' @@ -335,4 +337,5 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): sched.schedule_prep_resize(self.context, image, request_spec, filter_properties, instance, instance_type, reservations) - self.assertEqual(['host'], filter_properties['retry']['hosts']) + self.assertEqual([('host', 'node')], + filter_properties['retry']['hosts']) diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py index 9a0abb83c..1da29a7a7 100644 --- a/nova/tests/scheduler/test_host_filters.py +++ b/nova/tests/scheduler/test_host_filters.py @@ -1269,18 +1269,22 @@ class HostFiltersTestCase(test.TestCase): self.assertTrue(filt_cls.host_passes(host, filter_properties)) def test_retry_filter_pass(self): - """Host not previously tried""" + """Node not previously tried""" filt_cls = self.class_map['RetryFilter']() - host = fakes.FakeHostState('host1', 'node1', {}) - retry = dict(num_attempts=1, hosts=['host2', 'host3']) + host = fakes.FakeHostState('host1', 'nodeX', {}) + retry = dict(num_attempts=2, + hosts=[('host1', 'node1'), # same host, different node + ('host2', 'node2'), # different host and node + ]) filter_properties = dict(retry=retry) self.assertTrue(filt_cls.host_passes(host, filter_properties)) def test_retry_filter_fail(self): - """Host was already tried""" + """Node was already tried""" filt_cls = self.class_map['RetryFilter']() host = fakes.FakeHostState('host1', 'node1', {}) - retry = dict(num_attempts=1, hosts=['host3', 'host1']) + retry = dict(num_attempts=1, + hosts=[('host1', 'node1')]) filter_properties = dict(retry=retry) self.assertFalse(filt_cls.host_passes(host, filter_properties)) |
