Merge "SameHostFilter should fail if host does not have instances"
This commit is contained in:
@@ -49,10 +49,10 @@ class SameHostFilter(filters.BaseHostFilter):
|
||||
|
||||
def host_passes(self, host_state, spec_obj):
|
||||
affinity_uuids = spec_obj.get_scheduler_hint('same_host')
|
||||
if affinity_uuids and host_state.instances:
|
||||
if affinity_uuids:
|
||||
overlap = utils.instance_uuids_overlap(host_state, affinity_uuids)
|
||||
return overlap
|
||||
# With no same_host key or no instances
|
||||
# With no same_host key
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,14 @@ class TestSameHostFilter(test.NoDBTestCase):
|
||||
scheduler_hints=dict(same_host=['same']))
|
||||
self.assertTrue(self.filt_cls.host_passes(host, spec_obj))
|
||||
|
||||
def test_affinity_same_filter_no_list_passes(self):
|
||||
host = fakes.FakeHostState('host1', 'node1', {})
|
||||
host.instances = {}
|
||||
spec_obj = objects.RequestSpec(
|
||||
context=mock.sentinel.ctx,
|
||||
scheduler_hints=dict(same_host=['same']))
|
||||
self.assertFalse(self.filt_cls.host_passes(host, spec_obj))
|
||||
|
||||
def test_affinity_same_filter_fails(self):
|
||||
inst1 = objects.Instance(uuid='different')
|
||||
host = fakes.FakeHostState('host1', 'node1', {})
|
||||
|
||||
Reference in New Issue
Block a user