From 3c756ac6597755b537cf6f7d27a5dcae2f3ed8c9 Mon Sep 17 00:00:00 2001 From: zhangyangyang Date: Wed, 25 Apr 2018 17:25:42 +0800 Subject: [PATCH] Remove ExactCoreFilter ExactDiskFilter ExactRamFilter ExactCoreFilter, ExactDiskFilter and ExactRamFilter were deprecated for removal in the Pike release [1] and are now being removed. Now scheduling will use the custom resource class defined for each baremetal node to make its selection. [1] I843353427c90142a366ae9ca63ee4298b4f3ecd4 Change-Id: Ie25a5f6c28c20f589016791970da8d5849ec291c --- doc/source/admin/configuration/schedulers.rst | 17 ------ nova/conf/scheduler.py | 3 - nova/scheduler/filters/exact_core_filter.py | 58 ------------------- nova/scheduler/filters/exact_disk_filter.py | 52 ----------------- nova/scheduler/filters/exact_ram_filter.py | 49 ---------------- .../filters/test_exact_core_filter.py | 48 --------------- .../filters/test_exact_disk_filter.py | 42 -------------- .../filters/test_exact_ram_filter.py | 42 -------------- ...remove_exact_filters-2fd96171b93d7413.yaml | 11 ++++ 9 files changed, 11 insertions(+), 311 deletions(-) delete mode 100644 nova/scheduler/filters/exact_core_filter.py delete mode 100644 nova/scheduler/filters/exact_disk_filter.py delete mode 100644 nova/scheduler/filters/exact_ram_filter.py delete mode 100644 nova/tests/unit/scheduler/filters/test_exact_core_filter.py delete mode 100644 nova/tests/unit/scheduler/filters/test_exact_disk_filter.py delete mode 100644 nova/tests/unit/scheduler/filters/test_exact_ram_filter.py create mode 100644 releasenotes/notes/remove_exact_filters-2fd96171b93d7413.yaml diff --git a/doc/source/admin/configuration/schedulers.rst b/doc/source/admin/configuration/schedulers.rst index 66a98fe3cd77..d085d8f383da 100644 --- a/doc/source/admin/configuration/schedulers.rst +++ b/doc/source/admin/configuration/schedulers.rst @@ -416,23 +416,6 @@ greater than ``1.0``: space, as the value approaching ``0`` may result in the incorrect functioning of instances using it at the moment. -ExactCoreFilter ---------------- - -Only schedules instances on hosts if host has the exact number of CPU cores. - -ExactDiskFilter ---------------- - -Only schedules instances on hosts if host has the exact amount of disk -available. - -ExactRamFilter --------------- - -Only schedules instances on hosts if host has the exact number of RAM -available. - .. _ImagePropertiesFilter: ImagePropertiesFilter diff --git a/nova/conf/scheduler.py b/nova/conf/scheduler.py index 080fd7f67f6c..a36425e5c16e 100644 --- a/nova/conf/scheduler.py +++ b/nova/conf/scheduler.py @@ -341,9 +341,6 @@ Related options: "ComputeFilter", "ComputeCapabilitiesFilter", "ImagePropertiesFilter", - "ExactRamFilter", - "ExactDiskFilter", - "ExactCoreFilter", ], deprecated_name="baremetal_scheduler_default_filters", deprecated_group="DEFAULT", diff --git a/nova/scheduler/filters/exact_core_filter.py b/nova/scheduler/filters/exact_core_filter.py deleted file mode 100644 index 6f79f25cb74f..000000000000 --- a/nova/scheduler/filters/exact_core_filter.py +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (c) 2014 OpenStack Foundation -# -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslo_log import log as logging - -from nova.i18n import _LW -from nova.scheduler import filters - -LOG = logging.getLogger(__name__) - - -class ExactCoreFilter(filters.BaseHostFilter): - """Exact Core Filter.""" - - RUN_ON_REBUILD = False - - def __init__(self, *args, **kwargs): - super(ExactCoreFilter, self).__init__(*args, **kwargs) - LOG.warning('ExactCoreFilter is deprecated in Pike and will be ' - 'removed in a subsequent release.') - - def host_passes(self, host_state, spec_obj): - """Return True if host has the exact number of CPU cores.""" - if not host_state.vcpus_total: - # Fail safe - LOG.warning(_LW("VCPUs not set; assuming CPU collection broken")) - return False - - required_vcpus = spec_obj.vcpus - usable_vcpus = host_state.vcpus_total - host_state.vcpus_used - - if required_vcpus != usable_vcpus: - LOG.debug("%(host_state)s does not have exactly " - "%(requested_vcpus)s cores of usable vcpu, it has " - "%(usable_vcpus)s.", - {'host_state': host_state, - 'requested_vcpus': required_vcpus, - 'usable_vcpus': usable_vcpus}) - return False - - # NOTE(mgoddard): Setting the limit ensures that it is enforced in - # compute. This ensures that if multiple instances are scheduled to a - # single host, then all after the first will fail in the claim. - host_state.limits['vcpu'] = host_state.vcpus_total - return True diff --git a/nova/scheduler/filters/exact_disk_filter.py b/nova/scheduler/filters/exact_disk_filter.py deleted file mode 100644 index 519dd8ca8af6..000000000000 --- a/nova/scheduler/filters/exact_disk_filter.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (c) 2014 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslo_log import log as logging - -from nova.scheduler import filters - -LOG = logging.getLogger(__name__) - - -class ExactDiskFilter(filters.BaseHostFilter): - """Exact Disk Filter.""" - - RUN_ON_REBUILD = False - - def __init__(self, *args, **kwargs): - super(ExactDiskFilter, self).__init__(*args, **kwargs) - LOG.warning('ExactDiskFilter is deprecated in Pike and will be ' - 'removed in a subsequent release.') - - def host_passes(self, host_state, spec_obj): - """Return True if host has the exact amount of disk available.""" - requested_disk = (1024 * (spec_obj.root_gb + - spec_obj.ephemeral_gb) + - spec_obj.swap) - - if requested_disk != host_state.free_disk_mb: - LOG.debug("%(host_state)s does not have exactly " - "%(requested_disk)s MB usable disk, it " - "has %(usable_disk_mb)s.", - {'host_state': host_state, - 'requested_disk': requested_disk, - 'usable_disk_mb': host_state.free_disk_mb}) - return False - - # NOTE(mgoddard): Setting the limit ensures that it is enforced in - # compute. This ensures that if multiple instances are scheduled to a - # single host, then all after the first will fail in the claim. - host_state.limits['disk_gb'] = host_state.total_usable_disk_gb - return True diff --git a/nova/scheduler/filters/exact_ram_filter.py b/nova/scheduler/filters/exact_ram_filter.py deleted file mode 100644 index 123a1e11a856..000000000000 --- a/nova/scheduler/filters/exact_ram_filter.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (c) 2014 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslo_log import log as logging - -from nova.scheduler import filters - -LOG = logging.getLogger(__name__) - - -class ExactRamFilter(filters.BaseHostFilter): - """Exact RAM Filter.""" - - RUN_ON_REBUILD = False - - def __init__(self, *args, **kwargs): - super(ExactRamFilter, self).__init__(*args, **kwargs) - LOG.warning('ExactRamFilter is deprecated in Pike and will be ' - 'removed in a subsequent release.') - - def host_passes(self, host_state, spec_obj): - """Return True if host has the exact amount of RAM available.""" - requested_ram = spec_obj.memory_mb - if requested_ram != host_state.free_ram_mb: - LOG.debug("%(host_state)s does not have exactly " - "%(requested_ram)s MB usable RAM, it has " - "%(usable_ram)s MB.", - {'host_state': host_state, - 'requested_ram': requested_ram, - 'usable_ram': host_state.free_ram_mb}) - return False - - # NOTE(mgoddard): Setting the limit ensures that it is enforced in - # compute. This ensures that if multiple instances are scheduled to a - # single host, then all after the first will fail in the claim. - host_state.limits['memory_mb'] = host_state.total_usable_ram_mb - return True diff --git a/nova/tests/unit/scheduler/filters/test_exact_core_filter.py b/nova/tests/unit/scheduler/filters/test_exact_core_filter.py deleted file mode 100644 index 4a092f9136fe..000000000000 --- a/nova/tests/unit/scheduler/filters/test_exact_core_filter.py +++ /dev/null @@ -1,48 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from nova import objects -from nova.scheduler.filters import exact_core_filter -from nova import test -from nova.tests.unit.scheduler import fakes - - -class TestExactCoreFilter(test.NoDBTestCase): - - def setUp(self): - super(TestExactCoreFilter, self).setUp() - self.filt_cls = exact_core_filter.ExactCoreFilter() - - def test_exact_core_filter_passes(self): - spec_obj = objects.RequestSpec( - flavor=objects.Flavor(vcpus=1)) - vcpus = 3 - host = self._get_host({'vcpus_total': vcpus, 'vcpus_used': vcpus - 1}) - self.assertTrue(self.filt_cls.host_passes(host, spec_obj)) - self.assertEqual(host.limits.get('vcpu'), vcpus) - - def test_exact_core_filter_fails(self): - spec_obj = objects.RequestSpec( - flavor=objects.Flavor(vcpus=2)) - host = self._get_host({'vcpus_total': 3, 'vcpus_used': 2}) - self.assertFalse(self.filt_cls.host_passes(host, spec_obj)) - self.assertNotIn('vcpu', host.limits) - - def test_exact_core_filter_fails_host_vcpus_not_set(self): - spec_obj = objects.RequestSpec( - flavor=objects.Flavor(vcpus=1)) - host = self._get_host({}) - self.assertFalse(self.filt_cls.host_passes(host, spec_obj)) - self.assertNotIn('vcpu', host.limits) - - def _get_host(self, host_attributes): - return fakes.FakeHostState('host1', 'node1', host_attributes) diff --git a/nova/tests/unit/scheduler/filters/test_exact_disk_filter.py b/nova/tests/unit/scheduler/filters/test_exact_disk_filter.py deleted file mode 100644 index 4f590ff73c8a..000000000000 --- a/nova/tests/unit/scheduler/filters/test_exact_disk_filter.py +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from nova import objects -from nova.scheduler.filters import exact_disk_filter -from nova import test -from nova.tests.unit.scheduler import fakes - - -class TestExactDiskFilter(test.NoDBTestCase): - - def setUp(self): - super(TestExactDiskFilter, self).setUp() - self.filt_cls = exact_disk_filter.ExactDiskFilter() - - def test_exact_disk_filter_passes(self): - spec_obj = objects.RequestSpec( - flavor=objects.Flavor(root_gb=1, ephemeral_gb=1, swap=1024)) - disk_gb = 3 - host = self._get_host({'free_disk_mb': disk_gb * 1024, - 'total_usable_disk_gb': disk_gb}) - self.assertTrue(self.filt_cls.host_passes(host, spec_obj)) - self.assertEqual(host.limits.get('disk_gb'), disk_gb) - - def test_exact_disk_filter_fails(self): - spec_obj = objects.RequestSpec( - flavor=objects.Flavor(root_gb=1, ephemeral_gb=1, swap=1024)) - host = self._get_host({'free_disk_mb': 2 * 1024}) - self.assertFalse(self.filt_cls.host_passes(host, spec_obj)) - self.assertNotIn('disk_gb', host.limits) - - def _get_host(self, host_attributes): - return fakes.FakeHostState('host1', 'node1', host_attributes) diff --git a/nova/tests/unit/scheduler/filters/test_exact_ram_filter.py b/nova/tests/unit/scheduler/filters/test_exact_ram_filter.py deleted file mode 100644 index 0e37b2f0712e..000000000000 --- a/nova/tests/unit/scheduler/filters/test_exact_ram_filter.py +++ /dev/null @@ -1,42 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from nova import objects -from nova.scheduler.filters import exact_ram_filter -from nova import test -from nova.tests.unit.scheduler import fakes - - -class TestRamFilter(test.NoDBTestCase): - - def setUp(self): - super(TestRamFilter, self).setUp() - self.filt_cls = exact_ram_filter.ExactRamFilter() - - def test_exact_ram_filter_passes(self): - spec_obj = objects.RequestSpec( - flavor=objects.Flavor(memory_mb=1024)) - ram_mb = 1024 - host = self._get_host({'free_ram_mb': ram_mb, - 'total_usable_ram_mb': ram_mb}) - self.assertTrue(self.filt_cls.host_passes(host, spec_obj)) - self.assertEqual(host.limits.get('memory_mb'), ram_mb) - - def test_exact_ram_filter_fails(self): - spec_obj = objects.RequestSpec( - flavor=objects.Flavor(memory_mb=512)) - host = self._get_host({'free_ram_mb': 1024}) - self.assertFalse(self.filt_cls.host_passes(host, spec_obj)) - self.assertNotIn('memory_mb', host.limits) - - def _get_host(self, host_attributes): - return fakes.FakeHostState('host1', 'node1', host_attributes) diff --git a/releasenotes/notes/remove_exact_filters-2fd96171b93d7413.yaml b/releasenotes/notes/remove_exact_filters-2fd96171b93d7413.yaml new file mode 100644 index 000000000000..8192701269d9 --- /dev/null +++ b/releasenotes/notes/remove_exact_filters-2fd96171b93d7413.yaml @@ -0,0 +1,11 @@ +--- +upgrade: + - | + ExactCoreFilter, ExactDiskFilter and ExactRamFilter were deprecated for + removal in the 16.0.0 Pike release and have now been removed. + + Baremetal scheduling will use the custom resource class defined for + each baremetal node to make its selection. Refer to the ironic + documentation for more details: + + https://docs.openstack.org/ironic/latest/install/configure-nova-flavors.html#scheduling-resource-classes