Migrate instance_name_template to the base class

The [DEFAULT] instance_name_template parameter is used not only by
nova-api but by other services like nova-conductor or nova-compute.
This change migrate the parameter from the api class to the base class
so that users can configure the parameter for all services.

Backport note:
This avoids deprecating the existing parameter in stable branch.

Change-Id: I0f590f12017e743a17d989d3a1008faa9b840e87
(cherry picked from commit 73eb553202)
This commit is contained in:
Takashi Kajinami 2022-01-29 23:37:44 +09:00
parent 32e4e80330
commit 6d7e566c2e
4 changed files with 46 additions and 6 deletions

View File

@ -49,8 +49,10 @@
# Defaults to $::os_workers
#
# [*instance_name_template*]
# (optional) Template string to be used to generate instance names
# Defaults to $::os_service_default
# (optional) Template string to be used to generate instance names. Using
# this parameter might cause incomplete settings in case nova services are
# distributed among multiple nodes.
# Defaults to undef
#
# [*sync_db*]
# (optional) Run nova-manage db sync on api nodes after installing the package.
@ -191,7 +193,7 @@ class nova::api(
$sync_db = true,
$sync_db_api = true,
$db_online_data_migrations = false,
$instance_name_template = $::os_service_default,
$instance_name_template = undef,
$service_name = $::nova::params::api_service_name,
$metadata_service_name = $::nova::params::api_metadata_service_name,
$enable_proxy_headers_parsing = $::os_service_default,
@ -238,8 +240,20 @@ class nova::api(
warning('The use_forwarded_for parameter has been deprecated.')
}
nova_config {
'DEFAULT/instance_name_template': value => $instance_name_template;
if $instance_name_template != undef {
warning("The nova::api::instance_name_template parameter may result \
in incomplete settings in case nova services are distributed among multiple \
nodes. Use the nova::instance_name_template parameter instead.")
nova_config {
'DEFAULT/instance_name_template': value => $instance_name_template;
}
} else {
# Try best to clean up the parameter
if defined(Class['nova']) and $::nova::instance_name_template == undef {
nova_config {
'DEFAULT/instance_name_template': value => $::os_service_default;
}
}
}
# enable metadata in eventlet if we do not run metadata via wsgi (nova::metadata)

View File

@ -356,6 +356,10 @@
# (optional) domain to use for building the hostnames
# Defaults to $::os_service_default
#
# [*instance_name_template*]
# (optional) Template string to be used to generate instance names
# Defaults to undef
#
# DEPRECATED PARAMETERS
#
# [*auth_strategy*]
@ -459,6 +463,7 @@ class nova(
$purge_config = false,
$my_ip = $::os_service_default,
$dhcp_domain = $::os_service_default,
$instance_name_template = undef,
# DEPRECATED PARAMETERS
$auth_strategy = undef,
$os_region_name = undef,
@ -594,6 +599,14 @@ but should be one of: ssh-rsa, ssh-dsa, ssh-ecdsa.")
'DEFAULT/dhcp_domain': value => $dhcp_domain;
}
# TODO(tkajinam): Change the default value to $::os_service_default when we
# remove nova::api::instance_name_template after Antelope.
if $instance_name_template != undef {
nova_config {
'DEFAULT/instance_name_template': value => $instance_name_template;
}
}
oslo::messaging::rabbit {'nova_config':
rabbit_use_ssl => $rabbit_use_ssl,
heartbeat_timeout_threshold => $rabbit_heartbeat_timeout_threshold,

View File

@ -0,0 +1,9 @@
---
features:
- |
The new ``nova::instance_name_template`` parameter has been added so that
the ``[DEFAULT] instance_name_template`` option can be configured for
not only nova-api but also the other nova services.
The ``nova::api::instance_name_template`` parameter is still supported but
is no loger recomemnded because it can cause incomplete configurations in
case nova services are deployed in different nodes.

View File

@ -96,6 +96,9 @@ describe 'nova' do
is_expected.to contain_nova_config('console/ssl_ciphers').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('console/ssl_minimum_version').with_value('<SERVICE DEFAULT>')
is_expected.to contain_nova_config('DEFAULT/dhcp_domain').with_value('<SERVICE DEFAULT>')
# TODO(tkajinam): Uncomment this when we change default value of
# nova::instance_name_template
# is_expected.to contain_nova_config('DEFAULT/instance_name_template').with_value('<SERVICE DEFAULT>')
end
end
@ -155,7 +158,7 @@ describe 'nova' do
:console_ssl_ciphers => 'kEECDH+aECDSA+AES:kEECDH+AES+aRSA:kEDH+aRSA+AES',
:console_ssl_minimum_version => 'tlsv1_2',
:dhcp_domain => 'foo',
:instance_name_template => 'instance-%08x',
}
end
@ -248,6 +251,7 @@ describe 'nova' do
is_expected.to contain_nova_config('console/ssl_ciphers').with_value('kEECDH+aECDSA+AES:kEECDH+AES+aRSA:kEDH+aRSA+AES')
is_expected.to contain_nova_config('console/ssl_minimum_version').with_value('tlsv1_2')
is_expected.to contain_nova_config('DEFAULT/dhcp_domain').with_value('foo')
is_expected.to contain_nova_config('DEFAULT/instance_name_template').with_value('instance-%08x');
end
context 'with multiple notification_driver' do