diff options
author | Brian Elliott <brian.elliott@rackspace.com> | 2013-01-04 20:46:17 +0000 |
---|---|---|
committer | Brian Elliott <brian.elliott@rackspace.com> | 2013-01-04 21:19:11 +0000 |
commit | a62f01a1abe4fc49b099f0e0dfab827e5f78e80c (patch) | |
tree | a15b9f11619cd3cc8c0fb36aa2a6782d7d650c30 | |
parent | 48487f1a4b8f8fa538f90716e293ac8d67853311 (diff) | |
download | nova-a62f01a1abe4fc49b099f0e0dfab827e5f78e80c.tar.gz nova-a62f01a1abe4fc49b099f0e0dfab827e5f78e80c.tar.xz nova-a62f01a1abe4fc49b099f0e0dfab827e5f78e80c.zip |
Fix regression in RetryFilter
Fixes regression in RetryFilter. The RPC layer would convert the list
of tuples that comprised the previously attempted hosts to a list of
lists. The RetryFilter was attempting to compare a tuple to a list,
which failed.
bug 1096196
Change-Id: I30adf42daf5e86ccec0269eca1f84d06ed4beb59
-rw-r--r-- | nova/scheduler/filter_scheduler.py | 2 | ||||
-rw-r--r-- | nova/scheduler/filters/retry_filter.py | 11 | ||||
-rw-r--r-- | nova/tests/scheduler/test_filter_scheduler.py | 6 | ||||
-rw-r--r-- | nova/tests/scheduler/test_host_filters.py | 6 |
4 files changed, 14 insertions, 11 deletions
diff --git a/nova/scheduler/filter_scheduler.py b/nova/scheduler/filter_scheduler.py index ea9a39b6f..07a3f578a 100644 --- a/nova/scheduler/filter_scheduler.py +++ b/nova/scheduler/filter_scheduler.py @@ -165,7 +165,7 @@ class FilterScheduler(driver.Scheduler): if not retry: return hosts = retry['hosts'] - hosts.append((host, node)) + 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 108e4d206..91d2cb2a2 100644 --- a/nova/scheduler/filters/retry_filter.py +++ b/nova/scheduler/filters/retry_filter.py @@ -33,10 +33,13 @@ class RetryFilter(filters.BaseHostFilter): return True hosts = retry.get('hosts', []) - host = (host_state.host, host_state.nodename) + host = [host_state.host, host_state.nodename] - LOG.debug(_("Previously tried hosts: %(hosts)s. (host=%(host)s)") % - locals()) + passes = host not in hosts + pass_msg = "passes" if passes else "fails" + + LOG.debug(_("Host %(host)s %(pass_msg)s. Previously tried hosts: " + "%(hosts)s") % locals()) # Host passes if it's not in the list of previously attempted hosts: - return host not in hosts + return passes diff --git a/nova/tests/scheduler/test_filter_scheduler.py b/nova/tests/scheduler/test_filter_scheduler.py index 673e64997..4d7fb02ec 100644 --- a/nova/tests/scheduler/test_filter_scheduler.py +++ b/nova/tests/scheduler/test_filter_scheduler.py @@ -287,7 +287,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): hosts = filter_properties['retry']['hosts'] self.assertEqual(1, len(hosts)) - self.assertEqual((host, node), hosts[0]) + self.assertEqual([host, node], hosts[0]) def test_post_select_populate(self): """Test addition of certain filter props after a node is selected""" @@ -300,7 +300,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase): sched._post_select_populate_filter_properties(filter_properties, host_state) - self.assertEqual(('host', 'node'), + self.assertEqual(['host', 'node'], filter_properties['retry']['hosts'][0]) self.assertEqual({'vcpus': 5}, host_state.limits) @@ -337,5 +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', 'node')], + 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 f291e8112..e56278648 100644 --- a/nova/tests/scheduler/test_host_filters.py +++ b/nova/tests/scheduler/test_host_filters.py @@ -1272,8 +1272,8 @@ class HostFiltersTestCase(test.TestCase): filt_cls = self.class_map['RetryFilter']() host = fakes.FakeHostState('host1', 'nodeX', {}) retry = dict(num_attempts=2, - hosts=[('host1', 'node1'), # same host, different node - ('host2', 'node2'), # different host and node + 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)) @@ -1283,7 +1283,7 @@ class HostFiltersTestCase(test.TestCase): filt_cls = self.class_map['RetryFilter']() host = fakes.FakeHostState('host1', 'node1', {}) retry = dict(num_attempts=1, - hosts=[('host1', 'node1')]) + hosts=[['host1', 'node1']]) filter_properties = dict(retry=retry) self.assertFalse(filt_cls.host_passes(host, filter_properties)) |