From 7e2f5c7d340a0131ac083ed036e417976d6342da Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 18 Apr 2016 17:17:30 -0400 Subject: [PATCH] Remove deprecated ability to load scheduler_host_manager from path The ability to load the scheduler_host_manager from a random classpath was deprecated in Mitaka. This removes that ability so that only the entrypoints in Nova's setup.cfg can be used to load the scheduler host manager. The scheduler_host_manager config option is updated to only allow the choices that are currently in the setup.cfg. And a release note is added for the upgrade impact of dropping the deprecated classpath loading ability. Change-Id: I886c74afac02d100d472b78522e8295748276e4d Related-Bug: #1403020 --- nova/conf/scheduler.py | 5 +--- nova/scheduler/driver.py | 29 +++---------------- nova/tests/unit/scheduler/test_scheduler.py | 18 ------------ ...-host-mgr-class-load-2a86749a38f0688d.yaml | 6 ++++ 4 files changed, 11 insertions(+), 47 deletions(-) create mode 100644 releasenotes/notes/rm-sched-host-mgr-class-load-2a86749a38f0688d.yaml diff --git a/nova/conf/scheduler.py b/nova/conf/scheduler.py index b6126e9eb0..978e6ba9b0 100644 --- a/nova/conf/scheduler.py +++ b/nova/conf/scheduler.py @@ -245,6 +245,7 @@ configuration. sched_driver_host_mgr_opt = cfg.StrOpt("scheduler_host_manager", default="host_manager", + choices=("host_manager", "ironic_host_manager"), help=""" The scheduler host manager to use, which manages the in-memory picture of the hosts that the scheduler uses. @@ -255,10 +256,6 @@ namespace 'nova.scheduler.host_manager' of file 'setup.cfg'. For example, option as of the Mitaka release is 'ironic_host_manager', which should be used if you're using Ironic to provision bare-metal instances. -This option also supports a full class path style, for example -"nova.scheduler.host_manager.HostManager", but note this support is deprecated -and will be dropped in the N release. - * Services that use this: ``nova-scheduler`` diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index a695fdcd1b..de0bcf9fae 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -22,12 +22,10 @@ Scheduler base class that all Schedulers should inherit from import abc from oslo_log import log as logging -from oslo_utils import importutils import six from stevedore import driver import nova.conf -from nova.i18n import _, _LW from nova import objects from nova import servicegroup @@ -41,29 +39,10 @@ class Scheduler(object): """The base class that all Scheduler classes should inherit from.""" def __init__(self): - try: - self.host_manager = driver.DriverManager( - "nova.scheduler.host_manager", - CONF.scheduler_host_manager, - invoke_on_load=True).driver - # TODO(Yingxin): Change to catch stevedore.exceptions.NoMatches - # after stevedore v1.9.0 - except RuntimeError: - # NOTE(Yingxin): Loading full class path is deprecated and - # should be removed in the N release. - try: - self.host_manager = importutils.import_object( - CONF.scheduler_host_manager) - LOG.warning(_LW("DEPRECATED: scheduler_host_manager uses " - "classloader to load %(path)s. This legacy " - "loading style will be removed in the " - "N release."), - {'path': CONF.scheduler_host_manager}) - except (ImportError, ValueError): - raise RuntimeError( - _("Cannot load host manager from configuration " - "scheduler_host_manager = %(conf)s."), - {'conf': CONF.scheduler_host_manager}) + self.host_manager = driver.DriverManager( + "nova.scheduler.host_manager", + CONF.scheduler_host_manager, + invoke_on_load=True).driver self.servicegroup_api = servicegroup.API() def run_periodic_tasks(self, context): diff --git a/nova/tests/unit/scheduler/test_scheduler.py b/nova/tests/unit/scheduler/test_scheduler.py index cbf7182ee3..571c90d3a5 100644 --- a/nova/tests/unit/scheduler/test_scheduler.py +++ b/nova/tests/unit/scheduler/test_scheduler.py @@ -23,7 +23,6 @@ from nova import context from nova import objects from nova.scheduler import caching_scheduler from nova.scheduler import chance -from nova.scheduler import driver from nova.scheduler import filter_scheduler from nova.scheduler import host_manager from nova.scheduler import ironic_host_manager @@ -208,23 +207,6 @@ class SchedulerInitTestCase(test.NoDBTestCase): self.flags(scheduler_host_manager='nonexist_host_manager') self.assertRaises(RuntimeError, self.driver_cls) - # NOTE(Yingxin): Loading full class path is deprecated and should be - # removed in the N release. - @mock.patch.object(driver.LOG, 'warning') - @mock.patch.object(host_manager.HostManager, '_init_instance_info') - @mock.patch.object(host_manager.HostManager, '_init_aggregates') - def test_init_using_classpath_to_hostmanager(self, - mock_init_agg, - mock_init_inst, - mock_warning): - self.flags( - scheduler_host_manager= - 'nova.scheduler.ironic_host_manager.IronicHostManager') - manager = self.driver_cls().host_manager - self.assertIsInstance(manager, ironic_host_manager.IronicHostManager) - warn_args, kwargs = mock_warning.call_args - self.assertIn("DEPRECATED", warn_args[0]) - class SchedulerTestCase(test.NoDBTestCase): """Test case for base scheduler driver class.""" diff --git a/releasenotes/notes/rm-sched-host-mgr-class-load-2a86749a38f0688d.yaml b/releasenotes/notes/rm-sched-host-mgr-class-load-2a86749a38f0688d.yaml new file mode 100644 index 0000000000..57d744c3b9 --- /dev/null +++ b/releasenotes/notes/rm-sched-host-mgr-class-load-2a86749a38f0688d.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - The ability to load a custom scheduler host manager via the + ``scheduler_host_manager`` configuration option was deprecated + in the 13.0.0 Mitaka release and is now removed in the 14.0.0 Newton + release.