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
This commit is contained in:
Brian Elliott
2013-01-04 20:46:17 +00:00
parent 48487f1a4b
commit a62f01a1ab
4 changed files with 14 additions and 11 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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'])

View File

@@ -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))