Fix return type in FilterScheduler._legacy_find_hosts
The FilterScheduler._schedule method should be returning a list of list of selected hosts. When include_alternatives is False in _legacy_find_hosts, it was only returning back a list of hosts, which would result in an IndexError when select_destinations() tries to take the first entry from each item in the list. Change-Id: Ia6c87900605d3604beb74b942b0e30575b814112 Closes-Bug: #1729445
This commit is contained in:
parent
824d796775
commit
a9d92553b3
|
@ -339,7 +339,8 @@ class FilterScheduler(driver.Scheduler):
|
|||
selections_to_return = self._get_alternate_hosts(
|
||||
selected_hosts, spec_obj, hosts, num, num_to_return)
|
||||
return selections_to_return
|
||||
return selected_hosts
|
||||
# No alternatives but we still need to return a list of lists of hosts
|
||||
return [[host] for host in selected_hosts]
|
||||
|
||||
@staticmethod
|
||||
def _consume_selected_host(selected_host, spec_obj):
|
||||
|
|
|
@ -84,7 +84,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
|||
mock_get_hosts.assert_called_once_with(spec_obj, all_host_states, 0)
|
||||
|
||||
self.assertEqual(len(selected_hosts), 1)
|
||||
self.assertEqual([host_state], selected_hosts)
|
||||
self.assertEqual([[host_state]], selected_hosts)
|
||||
|
||||
# Ensure that we have consumed the resources on the chosen host states
|
||||
host_state.consume_from_request.assert_called_once_with(spec_obj)
|
||||
|
@ -133,7 +133,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
|||
mock_get_hosts.assert_called_once_with(spec_obj, all_host_states, 0)
|
||||
|
||||
self.assertEqual(len(selected_hosts), 1)
|
||||
self.assertEqual([host_state], selected_hosts)
|
||||
self.assertEqual([[host_state]], selected_hosts)
|
||||
|
||||
# Ensure that we have consumed the resources on the chosen host states
|
||||
host_state.consume_from_request.assert_called_once_with(spec_obj)
|
||||
|
|
Loading…
Reference in New Issue