From 5f21ea7124882f9f3ef4654d6b4421531d229b41 Mon Sep 17 00:00:00 2001 From: Andre Ruiz Date: Tue, 19 Feb 2019 11:10:52 -0300 Subject: [PATCH] Implement new option: enable_new_services This change implements a new option in config.yaml that allows services to come up disabled and be manually enabled later. Change-Id: I345b56e347b63650ee3df07773ccb2e333610355 Closes-Bug: #1758776 --- config.yaml | 16 ++++++++++++++++ hooks/nova_cc_context.py | 1 + templates/icehouse/nova.conf | 1 + templates/juno/nova.conf | 1 + templates/kilo/nova.conf | 1 + templates/liberty/nova.conf | 1 + templates/mitaka/nova.conf | 1 + templates/newton/nova.conf | 1 + templates/ocata/nova.conf | 3 ++- templates/pike/nova.conf | 3 ++- templates/rocky/nova.conf | 1 + unit_tests/test_nova_cc_contexts.py | 2 ++ 12 files changed, 30 insertions(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index 127c88b0..3aefdb52 100644 --- a/config.yaml +++ b/config.yaml @@ -182,6 +182,22 @@ options: Enable serial console access to instances using websockets (insecure). This is only supported on OpenStack Juno or later, and will disable the normal console-log output for an instance. + enable-new-services: + type: boolean + default: True + description: | + Enable new nova-compute services on this host automatically. + 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 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 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. worker-multiplier: type: float default: diff --git a/hooks/nova_cc_context.py b/hooks/nova_cc_context.py index 159d205d..1029dc53 100644 --- a/hooks/nova_cc_context.py +++ b/hooks/nova_cc_context.py @@ -304,6 +304,7 @@ class NovaConfigContext(ch_context.WorkerConfigContext): ctxt['disk_allocation_ratio'] = hookenv.config('disk-allocation-ratio') ctxt['cpu_allocation_ratio'] = hookenv.config('cpu-allocation-ratio') ctxt['ram_allocation_ratio'] = hookenv.config('ram-allocation-ratio') + ctxt['enable_new_services'] = hookenv.config('enable-new-services') addr = ch_ip.resolve_address(ch_ip.INTERNAL) ctxt['host_ip'] = ch_network_ip.format_ipv6_addr(addr) or addr ctxt['quota_instances'] = hookenv.config('quota-instances') diff --git a/templates/icehouse/nova.conf b/templates/icehouse/nova.conf index 66a78cea..b05096d3 100644 --- a/templates/icehouse/nova.conf +++ b/templates/icehouse/nova.conf @@ -27,6 +27,7 @@ osapi_compute_listen = {{ bind_host }} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} ec2_listen = {{ bind_host }} +enable_new_services = {{ enable_new_services }} osapi_compute_workers = {{ workers }} ec2_workers = {{ workers }} diff --git a/templates/juno/nova.conf b/templates/juno/nova.conf index 66ec1a0d..2fde0ff2 100644 --- a/templates/juno/nova.conf +++ b/templates/juno/nova.conf @@ -27,6 +27,7 @@ osapi_compute_listen = {{ bind_host }} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} ec2_listen = {{ bind_host }} +enable_new_services = {{ enable_new_services }} osapi_compute_workers = {{ workers }} ec2_workers = {{ workers }} diff --git a/templates/kilo/nova.conf b/templates/kilo/nova.conf index fa7f7058..05a64eaf 100644 --- a/templates/kilo/nova.conf +++ b/templates/kilo/nova.conf @@ -26,6 +26,7 @@ osapi_compute_listen = {{ bind_host }} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} ec2_listen = {{ bind_host }} +enable_new_services = {{ enable_new_services }} osapi_compute_workers = {{ workers }} ec2_workers = {{ workers }} diff --git a/templates/liberty/nova.conf b/templates/liberty/nova.conf index 63de0bf2..c5e10344 100644 --- a/templates/liberty/nova.conf +++ b/templates/liberty/nova.conf @@ -26,6 +26,7 @@ osapi_compute_listen = {{ bind_host }} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} ec2_listen = {{ bind_host }} +enable_new_services = {{ enable_new_services }} osapi_compute_workers = {{ workers }} ec2_workers = {{ workers }} diff --git a/templates/mitaka/nova.conf b/templates/mitaka/nova.conf index 72ef2922..d63990e3 100644 --- a/templates/mitaka/nova.conf +++ b/templates/mitaka/nova.conf @@ -24,6 +24,7 @@ use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} +enable_new_services = {{ enable_new_services }} osapi_compute_workers = {{ workers }} diff --git a/templates/newton/nova.conf b/templates/newton/nova.conf index 72f6d745..e0500b5f 100644 --- a/templates/newton/nova.conf +++ b/templates/newton/nova.conf @@ -24,6 +24,7 @@ use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} +enable_new_services = {{ enable_new_services }} osapi_compute_workers = {{ workers }} diff --git a/templates/ocata/nova.conf b/templates/ocata/nova.conf index c00918ad..b1623b63 100644 --- a/templates/ocata/nova.conf +++ b/templates/ocata/nova.conf @@ -21,6 +21,7 @@ use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} +enable_new_services = {{ enable_new_services }} {% if transport_url %} transport_url = {{ transport_url }} @@ -232,4 +233,4 @@ server_groups = {{ quota_server_groups }} {% endif -%} {% if quota_server_group_members is not none -%} server_group_members = {{ quota_server_group_members }} -{% endif -%} \ No newline at end of file +{% endif -%} diff --git a/templates/pike/nova.conf b/templates/pike/nova.conf index 5fbbb5b8..b44615db 100644 --- a/templates/pike/nova.conf +++ b/templates/pike/nova.conf @@ -21,6 +21,7 @@ use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} +enable_new_services = {{ enable_new_services }} {% if transport_url %} transport_url = {{ transport_url }} @@ -239,4 +240,4 @@ server_groups = {{ quota_server_groups }} {% endif -%} {% if quota_server_group_members is not none -%} server_group_members = {{ quota_server_group_members }} -{% endif -%} \ No newline at end of file +{% endif -%} diff --git a/templates/rocky/nova.conf b/templates/rocky/nova.conf index 594225e3..32cc368a 100644 --- a/templates/rocky/nova.conf +++ b/templates/rocky/nova.conf @@ -21,6 +21,7 @@ use_ipv6 = {{ use_ipv6 }} osapi_compute_listen = {{ bind_host }} metadata_host = {{ bind_host }} s3_listen = {{ bind_host }} +enable_new_services = {{ enable_new_services }} {% if transport_url %} transport_url = {{ transport_url }} diff --git a/unit_tests/test_nova_cc_contexts.py b/unit_tests/test_nova_cc_contexts.py index 7e1ae1df..bd6820af 100644 --- a/unit_tests/test_nova_cc_contexts.py +++ b/unit_tests/test_nova_cc_contexts.py @@ -353,6 +353,8 @@ class NovaComputeContextTests(CharmTestCase): self.assertEqual(ctxt['quota_server_group_members'], self.config('quota-server-group-members')) self.assertEqual(ctxt['quota_server_group_members'], None) + self.assertEqual(ctxt['enable_new_services'], + self.config('enable-new-services')) _pci_alias1 = { "name": "IntelNIC",