Merge "Refactor api service management"

This commit is contained in:
Zuul
2025-09-29 15:36:22 +00:00
committed by Gerrit Code Review
2 changed files with 32 additions and 48 deletions

View File

@@ -155,42 +155,42 @@ class cinder::api (
} }
if $manage_service { if $manage_service {
if $enabled { case $service_name {
$ensure = 'running' 'httpd': {
} else { Service <| title == 'httpd' |> { tag +> 'cinder-service' }
$ensure = 'stopped'
}
if $service_name == $cinder::params::api_service { service { 'cinder-api':
service { 'cinder-api': ensure => 'stopped',
ensure => $ensure, name => $cinder::params::api_service,
name => $cinder::params::api_service, enable => false,
enable => $enabled, tag => ['cinder-service'],
hasstatus => true, }
tag => 'cinder-service',
# we need to make sure cinder-api/eventlet is stopped before trying to start apache
Service['cinder-api'] -> Service['httpd']
# On any api-paste.ini config change, we must restart Cinder API.
Cinder_api_paste_ini<||> ~> Service['httpd']
} }
default: {
$service_ensure = $enabled ? {
true => 'running',
default => 'stopped',
}
# On any api-paste.ini config change, we must restart Cinder API. service { 'cinder-api':
Cinder_api_paste_ini<||> ~> Service['cinder-api'] ensure => $service_ensure,
# On any uwsgi config change, we must restart Cinder API. name => $service_name,
Cinder_api_uwsgi_config<||> ~> Service['cinder-api'] enable => $enabled,
} elsif $service_name == 'httpd' { hasstatus => true,
service { 'cinder-api': tag => 'cinder-service',
ensure => 'stopped', }
name => $cinder::params::api_service,
enable => false, # On any api-paste.ini config change, we must restart Cinder API.
tag => ['cinder-service'], Cinder_api_paste_ini<||> ~> Service['cinder-api']
# On any uwsgi config change, we must restart Cinder API.
Cinder_api_uwsgi_config<||> ~> Service['cinder-api']
} }
Service <| title == 'httpd' |> { tag +> 'cinder-service' }
# we need to make sure cinder-api/eventlet is stopped before trying to start apache
Service['cinder-api'] -> Service[$service_name]
# On any api-paste.ini config change, we must restart Cinder API.
Cinder_api_paste_ini<||> ~> Service[$service_name]
} else {
fail("Invalid service_name. Either cinder-api/openstack-cinder-api for \
running as a standalone service, or httpd for being run by a httpd server")
} }
} }

View File

@@ -174,22 +174,6 @@ describe 'cinder::api' do
end end
end end
context 'when service_name is not valid' do
let :params do
req_params.merge!({ :service_name => 'foobar' })
end
let :pre_condition do
"include apache
class { 'cinder': }
class { 'cinder::keystone::authtoken':
password => 'foo',
}"
end
it_raises 'a Puppet::Error', /Invalid service_name/
end
context 'with SSL socket options set' do context 'with SSL socket options set' do
let :params do let :params do
req_params.merge!({ req_params.merge!({