diff --git a/nova/conf/compute.py b/nova/conf/compute.py index f4d26e51af11..4ae4528c80d3 100644 --- a/nova/conf/compute.py +++ b/nova/conf/compute.py @@ -1098,19 +1098,21 @@ Possible values: cfg.BoolOpt('enable_new_services', default=True, help=""" -Enable new services on this host automatically. +Enable new nova-compute services on this host automatically. -When a new service (for example "nova-compute") starts up, it gets +When a new nova-compute service starts up, it gets registered in the database as an enabled service. Sometimes it can be useful -to register new services in disabled state and then enabled them at a later -point in time. This option can set this behavior for all services per host. +to register new compute services in disabled state and then enabled them at a +later point in time. This option only sets this behavior for nova-compute +services, it does not auto-disable other services like nova-conductor, +nova-scheduler, nova-consoleauth, or nova-osapi_compute. Possible values: -* ``True``: Each new service is enabled as soon as it registers itself. -* ``False``: Services must be enabled via a REST API call or with the CLI - with ``nova service-enable ``, otherwise they are not - ready to use. +* ``True``: Each new compute service is enabled as soon as it registers itself. +* ``False``: Compute services must be enabled via an os-services REST API call + or with the CLI with ``nova service-enable ``, otherwise + they are not ready to use. """), cfg.StrOpt('instance_name_template', default='instance-%08x', diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index cb9d4036d98d..84c0c1894e40 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -585,8 +585,13 @@ def service_get_by_compute_host(context, host): def service_create(context, values): service_ref = models.Service() service_ref.update(values) - if not CONF.enable_new_services: - msg = _("New service disabled due to config option.") + # We only auto-disable nova-compute services since those are the only + # ones that can be enabled using the os-services REST API and they are + # the only ones where being disabled means anything. It does + # not make sense to be able to disable non-compute services like + # nova-scheduler or nova-osapi_compute since that does nothing. + if not CONF.enable_new_services and values.get('binary') == 'nova-compute': + msg = _("New compute service disabled due to config option.") service_ref.disabled = True service_ref.disabled_reason = msg try: diff --git a/nova/tests/unit/db/test_db_api.py b/nova/tests/unit/db/test_db_api.py index af0064058ceb..77eaf1316ef1 100644 --- a/nova/tests/unit/db/test_db_api.py +++ b/nova/tests/unit/db/test_db_api.py @@ -3515,15 +3515,24 @@ class ServiceTestCase(test.TestCase, ModelsObjectComparatorMixin): def test_service_create_disabled(self): self.flags(enable_new_services=False) - service = self._create_service({}) + service = self._create_service({'binary': 'nova-compute'}) self.assertTrue(service['disabled']) def test_service_create_disabled_reason(self): self.flags(enable_new_services=False) - service = self._create_service({}) - msg = "New service disabled due to config option." + service = self._create_service({'binary': 'nova-compute'}) + msg = "New compute service disabled due to config option." self.assertEqual(msg, service['disabled_reason']) + def test_service_create_disabled_non_compute_ignored(self): + """Tests that enable_new_services=False has no effect on + auto-disabling a new non-nova-compute service. + """ + self.flags(enable_new_services=False) + service = self._create_service({'binary': 'nova-scheduler'}) + self.assertFalse(service['disabled']) + self.assertIsNone(service['disabled_reason']) + def test_service_destroy(self): service1 = self._create_service({}) service2 = self._create_service({'host': 'fake_host2'}) diff --git a/releasenotes/notes/enable_new_services-compute-only-0abf5d3cbec40eb2.yaml b/releasenotes/notes/enable_new_services-compute-only-0abf5d3cbec40eb2.yaml new file mode 100644 index 000000000000..b4cb436b380e --- /dev/null +++ b/releasenotes/notes/enable_new_services-compute-only-0abf5d3cbec40eb2.yaml @@ -0,0 +1,9 @@ +--- +other: + - | + The ``[DEFAULT]/enable_new_services`` configuration option will now only be + used to auto-disable new nova-compute services. Other services like + nova-conductor, nova-scheduler and nova-osapi_compute will not be + auto-disabled since disabling them does nothing functionally, and starting + in Pike the ``PUT /os-services/enable`` REST API will not be able to find + non-compute services to enable them.