From 43dd054685d5df87b2dfd63bb21b62c079f22c25 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 5 Apr 2019 13:50:01 +0100 Subject: [PATCH] filters: Stop handling cells v1 Part of blueprint remove-cells-v1 Change-Id: Ie8c934b131df75ad275226d357b8ce5cb9453738 --- nova/filters.py | 28 ++++++++------------ nova/tests/unit/scheduler/test_filters.py | 31 ----------------------- 2 files changed, 10 insertions(+), 49 deletions(-) diff --git a/nova/filters.py b/nova/filters.py index 4793e229c7..f7679e238e 100644 --- a/nova/filters.py +++ b/nova/filters.py @@ -104,28 +104,20 @@ class BaseFilterHandler(loadables.BaseLoader): {'cls_name': cls_name, 'obj_len': len(list_objs)}) if not list_objs: # Log the filtration history - # NOTE(sbauza): Since the Cells scheduler still provides a legacy - # dictionary for filter_props, and since we agreed on not modifying - # the Cells scheduler to support that because of Cells v2, we - # prefer to define a compatible way to address both types - if isinstance(spec_obj, dict): - rspec = spec_obj.get("request_spec", {}) - inst_props = rspec.get("instance_properties", {}) - inst_uuid = inst_props.get("uuid", "") - else: - inst_uuid = spec_obj.instance_uuid - msg_dict = {"inst_uuid": inst_uuid, - "str_results": str(full_filter_results), - } + msg_dict = { + "inst_uuid": spec_obj.instance_uuid, + "str_results": str(full_filter_results), + } full_msg = ("Filtering removed all hosts for the request with " "instance ID " "'%(inst_uuid)s'. Filter results: %(str_results)s" ) % msg_dict - msg_dict["str_results"] = str(part_filter_results) - part_msg = _LI("Filtering removed all hosts for the request with " - "instance ID " - "'%(inst_uuid)s'. Filter results: %(str_results)s" - ) % msg_dict LOG.debug(full_msg) + + msg_dict["str_results"] = str(part_filter_results) + part_msg = ("Filtering removed all hosts for the request with " + "instance ID " + "'%(inst_uuid)s'. Filter results: %(str_results)s" + ) % msg_dict LOG.info(part_msg) return list_objs diff --git a/nova/tests/unit/scheduler/test_filters.py b/nova/tests/unit/scheduler/test_filters.py index ce4dde6ee1..75f2482a81 100644 --- a/nova/tests/unit/scheduler/test_filters.py +++ b/nova/tests/unit/scheduler/test_filters.py @@ -234,34 +234,3 @@ class FiltersTestCase(test.NoDBTestCase): cargs = mock_log.call_args[0][0] self.assertIn("with instance ID '%s'" % fake_uuid, cargs) self.assertIn(exp_output, cargs) - - def test_get_filtered_objects_compatible_with_filt_props_dicts(self): - LOG = filters.LOG - - class FilterA(filters.BaseFilter): - def filter_all(self, list_objs, spec_obj): - # return all but the first object - return list_objs[1:] - - class FilterB(filters.BaseFilter): - def filter_all(self, list_objs, spec_obj): - # return an empty list - return [] - - filter_a = FilterA() - filter_b = FilterB() - all_filters = [filter_a, filter_b] - hosts = ["Host0", "Host1", "Host2"] - fake_uuid = uuids.instance - filt_props = {"request_spec": {"instance_properties": { - "uuid": fake_uuid}}} - with mock.patch.object(LOG, "info") as mock_log: - result = self.filter_handler.get_filtered_objects( - all_filters, hosts, filt_props) - self.assertFalse(result) - # FilterA should leave Host1 and Host2; FilterB should leave None. - exp_output = ("['FilterA: (start: 3, end: 2)', " - "'FilterB: (start: 2, end: 0)']") - cargs = mock_log.call_args[0][0] - self.assertIn("with instance ID '%s'" % fake_uuid, cargs) - self.assertIn(exp_output, cargs)