Refactor api service management

Drop validation of service name which is not implemented for
the other daemons, to simplify handling of the provided service name.

This allows us to more easily offload the service name definition to
hiera data in the near future.

Change-Id: I08f1e4b15f6d18e2af605230216270da4ec89fc6
Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
Takashi Kajinami
2025-09-27 00:46:12 +09:00
parent 0da5add448
commit 1328f9c5cf
2 changed files with 54 additions and 70 deletions

View File

@@ -143,8 +143,8 @@ class nova::api (
Boolean $sync_db = true, Boolean $sync_db = true,
Boolean $sync_db_api = true, Boolean $sync_db_api = true,
Boolean $db_online_data_migrations = false, Boolean $db_online_data_migrations = false,
$service_name = $nova::params::api_service_name, String[1] $service_name = $nova::params::api_service_name,
$metadata_service_name = $nova::params::api_metadata_service_name, Optional[String[1]] $metadata_service_name = $nova::params::api_metadata_service_name,
$enable_proxy_headers_parsing = $facts['os_service_default'], $enable_proxy_headers_parsing = $facts['os_service_default'],
$max_request_body_size = $facts['os_service_default'], $max_request_body_size = $facts['os_service_default'],
$max_limit = $facts['os_service_default'], $max_limit = $facts['os_service_default'],
@@ -183,14 +183,8 @@ class nova::api (
} }
} }
if $service_name == $nova::params::api_service_name { case $service_name {
$service_enabled = $enabled 'httpd': {
if $manage_service {
Nova_api_paste_ini<||> ~> Service['nova-api']
Nova_api_uwsgi_config<||> ~> Service['nova-api']
}
} elsif $service_name == 'httpd' {
$service_enabled = false $service_enabled = false
policy_rcd { 'nova-api': policy_rcd { 'nova-api':
@@ -203,16 +197,22 @@ class nova::api (
Service <| title == 'httpd' |> { tag +> 'nova-service' } Service <| title == 'httpd' |> { tag +> 'nova-service' }
# make sure we start apache before nova-api and nova-metadata-api are # make sure we start apache before nova-api and nova-metadata-api are
# stopped to avoid binding issues # stopped to avoid binding issues
Service['nova-api'] -> Service[$service_name] Service['nova-api'] -> Service['httpd']
if $metadata_service_name { if $metadata_service_name {
Service['nova-api-metadata'] -> Service[$service_name] Service['nova-api-metadata'] -> Service['httpd']
} }
Nova_api_paste_ini<||> ~> Service[$service_name] Nova_api_paste_ini<||> ~> Service['httpd']
}
}
default: {
$service_enabled = $enabled
if $manage_service {
Nova_api_paste_ini<||> ~> Service['nova-api']
Nova_api_uwsgi_config<||> ~> Service['nova-api']
}
} }
} else {
fail("Invalid service_name. Either nova-api/openstack-nova-api for running \
as a standalone service, or httpd for being run by a httpd server")
} }
nova::generic_service { 'api': nova::generic_service { 'api':

View File

@@ -157,22 +157,6 @@ describe 'nova::api' do
end end
end end
context 'when service_name is not valid' do
before do
params.merge!({ :service_name => 'foobar' })
end
let :pre_condition do
"include apache
include nova
class { 'nova::keystone::authtoken':
password => 'a_big_secret',
}"
end
it_raises 'a Puppet::Error', /Invalid service_name/
end
end end
shared_examples 'nova-api on Debian' do shared_examples 'nova-api on Debian' do