Remove dict compat from populate_filter_properties

The only callers of populate_filter_properties are conductor
methods and they all pass a Selection object so we can fulfill
the TODO and remove the dict compat. Note that the callers have
to pass a Selection object because they ask select_destinations
to return_objects=True and if there was a pinned RPC version the
select_destinations call would fail with
SelectionObjectsWithOldRPCVersionNotSupported. Point being, we
don't need to worry about old RPC compat code passing a dict rather
than a Selection object.

Change-Id: I076b84d46e5b2ff3bb6ed4d0c361683097c4c014
This commit is contained in:
Matt Riedemann 2019-12-06 09:32:47 -05:00
parent 103b8c984f
commit ec59ab5205
2 changed files with 11 additions and 19 deletions

View File

@ -815,20 +815,18 @@ def build_filter_properties(scheduler_hints, forced_host,
def populate_filter_properties(filter_properties, selection):
"""Add additional information to the filter properties after a node has
been selected by the scheduling process.
:param filter_properties: dict of filter properties (the legacy form of
the RequestSpec)
:param selection: Selection object
"""
if isinstance(selection, dict):
# TODO(edleafe): remove support for dicts
host = selection['host']
nodename = selection['nodename']
limits = selection['limits']
host = selection.service_host
nodename = selection.nodename
# Need to convert SchedulerLimits object to older dict format.
if "limits" in selection and selection.limits is not None:
limits = selection.limits.to_dict()
else:
host = selection.service_host
nodename = selection.nodename
# Need to convert SchedulerLimits object to older dict format.
if "limits" in selection and selection.limits is not None:
limits = selection.limits.to_dict()
else:
limits = {}
limits = {}
# Adds a retry entry for the selected compute host and node:
_add_retry_host(filter_properties, host, nodename)

View File

@ -153,7 +153,7 @@ class SchedulerUtilsTestCase(test.NoDBTestCase):
self.assertNotIn('forced_host', filt_props)
self.assertNotIn('forced_node', filt_props)
def _test_populate_filter_props(self, selection_obj=True,
def _test_populate_filter_props(self,
with_retry=True,
force_hosts=None,
force_nodes=None,
@ -183,9 +183,6 @@ class SchedulerUtilsTestCase(test.NoDBTestCase):
memory_mb=3, numa_topology=None)
selection = objects.Selection(service_host="fake-host",
nodename="fake-node", limits=fake_limits)
if not selection_obj:
selection = selection.to_dict()
fake_limits = fake_limits.to_dict()
scheduler_utils.populate_filter_properties(filter_properties,
selection)
@ -219,9 +216,6 @@ class SchedulerUtilsTestCase(test.NoDBTestCase):
def test_populate_filter_props(self):
self._test_populate_filter_props()
def test_populate_filter_props_host_dict(self):
self._test_populate_filter_props(selection_obj=False)
def test_populate_filter_props_no_retry(self):
self._test_populate_filter_props(with_retry=False)