From 3eefcce2553856a1635a62fecf73cd9a2d9097cb Mon Sep 17 00:00:00 2001 From: Sylvain Bauza Date: Tue, 18 Jul 2017 16:33:49 +0200 Subject: [PATCH] Accept any scheduler driver entrypoint We broke the possibility in Ocata with Icdcf839b6d28893694bfa1355e9dbe8dbb5ea8c3 to use other scheduler drivers but the ones we provided in tree. Unfortunately, that was an incidental change without any communication. Removing the choices kwarg will allow operators to run their own scheduler driver. Whether Nova would stop supporting custom drivers would require a totally separate change which would clearly communicate thru a deprecation notice but that is not the intent for that bugfix, which aims only to bring back the capability. Change-Id: I346881bc3bc48794b139cc471be1de11c49b8ee3 Closes-Bug: #1704788 (cherry picked from commit 1e5c7b52a403e708dba5a069dd86b628a4cb952c) --- nova/conf/scheduler.py | 33 +++++++++++-------- nova/tests/unit/scheduler/test_scheduler.py | 7 ++-- .../notes/bug-1704788-490797827bae9142.yaml | 5 +++ 3 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 releasenotes/notes/bug-1704788-490797827bae9142.yaml diff --git a/nova/conf/scheduler.py b/nova/conf/scheduler.py index 73091c554ad2..6b69f9d1a2d3 100644 --- a/nova/conf/scheduler.py +++ b/nova/conf/scheduler.py @@ -57,27 +57,32 @@ uses. The options values are chosen from the entry points under the namespace """), cfg.StrOpt("driver", default="filter_scheduler", - choices=("filter_scheduler", "caching_scheduler", - "chance_scheduler", "fake_scheduler"), deprecated_name="scheduler_driver", deprecated_group="DEFAULT", help=""" -The class of the driver used by the scheduler. +The class of the driver used by the scheduler. This should be chosen from one +of the entrypoints under the namespace 'nova.scheduler.driver' of file +'setup.cfg'. If nothing is specified in this option, the 'filter_scheduler' is +used. -The options are chosen from the entry points under the namespace -'nova.scheduler.driver' in 'setup.cfg'. +Other options are: + +* 'caching_scheduler' which aggressively caches the system state for better + individual scheduler performance at the risk of more retries when running + multiple schedulers. +* 'chance_scheduler' which simply picks a host at random. +* 'fake_scheduler' which is used for testing. Possible values: -* A string, where the string corresponds to the class name of a scheduler - driver. There are a number of options available: -** 'caching_scheduler', which aggressively caches the system state for better - individual scheduler performance at the risk of more retries when running - multiple schedulers -** 'chance_scheduler', which simply picks a host at random -** 'fake_scheduler', which is used for testing -** A custom scheduler driver. In this case, you will be responsible for - creating and maintaining the entry point in your 'setup.cfg' file +* Any of the drivers included in Nova: +** filter_scheduler +** caching_scheduler +** chance_scheduler +** fake_scheduler +* You may also set this to the entry point name of a custom scheduler driver, + but you will be responsible for creating and maintaining it in your setup.cfg + file. """), cfg.IntOpt("periodic_task_interval", default=60, diff --git a/nova/tests/unit/scheduler/test_scheduler.py b/nova/tests/unit/scheduler/test_scheduler.py index f6d466503e23..c4dca61c75a3 100644 --- a/nova/tests/unit/scheduler/test_scheduler.py +++ b/nova/tests/unit/scheduler/test_scheduler.py @@ -18,7 +18,6 @@ Tests For Scheduler """ import mock -import testtools from nova import context from nova import objects @@ -69,8 +68,10 @@ class SchedulerManagerInitTestCase(test.NoDBTestCase): def test_init_nonexist_schedulerdriver(self, mock_init_agg, mock_init_inst): - with testtools.ExpectedException(ValueError): - self.flags(driver='nonexist_scheduler', group='scheduler') + self.flags(driver='nonexist_scheduler', group='scheduler') + # The entry point has to be defined in setup.cfg and nova-scheduler has + # to be deployed again before using a custom value. + self.assertRaises(RuntimeError, self.manager_cls) class SchedulerManagerTestCase(test.NoDBTestCase): diff --git a/releasenotes/notes/bug-1704788-490797827bae9142.yaml b/releasenotes/notes/bug-1704788-490797827bae9142.yaml new file mode 100644 index 000000000000..1f93bd863fc6 --- /dev/null +++ b/releasenotes/notes/bug-1704788-490797827bae9142.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - Correctly allow the use of a custom scheduler driver by using the name of + the custom driver entry point in the ``[scheduler]/driver`` config option. + You must also update the entry point in ``setup.cfg``.