Add support for running neutron api by httpd+mod_wsgi

This change allows users to run neutron api by httpd+mod_wsgi with
an independent rpc worker service. Setting service_name to httpd is no
longer supported, because it results in incomplete deployment without
rpc services.

Change-Id: Id530e02e49e5fc020e13760bfcf38615da9da86a
This commit is contained in:
Takashi Kajinami 2021-06-27 02:29:53 +09:00
parent b97976181f
commit ef06ac48b5
5 changed files with 147 additions and 42 deletions

View File

@ -90,11 +90,11 @@ class neutron::keystone::auth (
include neutron::deps
if $configure_endpoint {
Keystone_endpoint["${region}/${service_name}::${service_type}"] ~> Service <| tag == 'neutron-server-eventlet' |>
Keystone_endpoint["${region}/${service_name}::${service_type}"] -> Anchor['neutron::service::end']
}
if $configure_user_role {
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| tag == 'neutron-server-eventlet' |>
Keystone_user_role["${auth_name}@${tenant}"] -> Anchor['neutron::service::end']
}
keystone::resource::service_identity { 'neutron':

View File

@ -79,7 +79,7 @@ class neutron::params {
} elsif($::osfamily == 'Debian') {
$nobody_user_group = 'nogroup'
$package_name = 'neutron-common'
if $::os_package_type =='debian' {
if $::operatingsystem == 'Debian' {
$ml2_server_package = false
$server_service = false
$server_package = false

View File

@ -397,19 +397,9 @@ class neutron::server (
tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
}
} elsif $service_name == 'httpd' {
include apache::params
service { 'neutron-server':
ensure => 'stopped',
name => $::neutron::params::server_service,
enable => false,
hasstatus => true,
hasrestart => true,
tag => ['neutron-service', 'neutron-db-sync-service'],
}
Service <| title == 'httpd' |> { tag +> 'neutron-service' }
# we need to make sure neutron-server is stopped before trying to start apache
Service[$::neutron::params::server_service] -> Service[$service_name]
fail('Use api_service_name and rpc_service_name to run api service by httpd')
} else {
warning('Support for arbitaly service name is deprecated')
# backward compatibility so operators can customize the service name.
service { 'neutron-server':
ensure => $service_ensure,
@ -421,14 +411,54 @@ class neutron::server (
}
}
} else {
if $api_service_name {
if $::neutron::params::server_service {
# we need to make sure neutron-server is stopped before trying to
# start separate services.
service { 'neutron-server':
ensure => $service_ensure,
name => $api_service_name,
enable => $enabled,
ensure => 'stopped',
name => $::neutron::params::server_service,
enable => false,
hasstatus => true,
hasrestart => true,
tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
tag => ['neutron-service'],
}
}
if $api_service_name {
if $api_service_name == 'httpd' {
include apache::params
Service <| title == 'httpd' |> { tag +> 'neutron-service' }
if $::neutron::params::server_service {
Service['neutron-server'] -> Service['httpd']
}
if $::neutron::params::api_service_name {
# we need to make sure api service is stopped before trying to
# start apache
service { 'neutron-api':
ensure => 'stopped',
name => $::neutron::params::api_service_name,
enable => false,
hasstatus => true,
hasrestart => true,
tag => ['neutron-service'],
}
Service['neutron-api'] -> Service['httpd']
}
} else {
service { 'neutron-api':
ensure => $service_ensure,
name => $api_service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
}
if $::neutron::params::server_service {
Service['neutron-server'] -> Service['neutron-api']
}
}
}
@ -441,6 +471,10 @@ class neutron::server (
hasrestart => true,
tag => ['neutron-service', 'neutron-db-sync-service'],
}
if $::neutron::params::server_service {
Service['neutron-server'] -> Service['neutron-rpc-server']
}
}
}
@ -464,6 +498,6 @@ class neutron::server (
'try_sleep' => '2',
}
}
create_resources('openstacklib::service_validation', $validation_cmd, {'subscribe' => 'Service[neutron-server]'})
create_resources('openstacklib::service_validation', $validation_cmd, {'subscribe' => 'Anchor[neutron::service::end]'})
}
}

View File

@ -0,0 +1,17 @@
---
features:
- |
Now ``neutron::server::api_service_name`` can accept and handle ``httpd``
as a valid service name, to run api service by httpd+mod_wsgi.
upgrade:
- |
The ``neutron::server::service_name`` parameter no longer accepts
``httpd`` as a valid service name. To run api service by httpd,
the ``neutron::server::api_service_name`` parameter should be used instead
along with the ``neutron::server::rpc_service_name``.
deprecations:
- |
Usage of arbitaly service name for the ``neutron::server::service_name``
has been deprecated and will be removed in a future release.

View File

@ -49,16 +49,36 @@ describe 'neutron::server' do
end
it 'configures neutron server service' do
should contain_service('neutron-server').with(
:name => platform_params[:server_service],
:enable => true,
:ensure => 'running',
:tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
)
should contain_service('neutron-server').that_subscribes_to('Anchor[neutron::service::begin]')
should contain_service('neutron-server').that_notifies('Anchor[neutron::service::end]')
if platform_params.has_key?(:server_service)
should contain_service('neutron-server').with(
:name => platform_params[:server_service],
:enable => true,
:ensure => 'running',
:tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
)
should contain_service('neutron-server').that_subscribes_to('Anchor[neutron::service::begin]')
should contain_service('neutron-server').that_notifies('Anchor[neutron::service::end]')
else
should contain_service('neutron-api').with(
:name => platform_params[:api_service_name],
:enable => true,
:ensure => 'running',
:tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
)
should contain_service('neutron-api').that_subscribes_to('Anchor[neutron::service::begin]')
should contain_service('neutron-api').that_notifies('Anchor[neutron::service::end]')
should contain_service('neutron-rpc-server').with(
:name => platform_params[:rpc_service_name],
:enable => true,
:ensure => 'running',
:tag => ['neutron-service', 'neutron-db-sync-service'],
)
should contain_service('neutron-rpc-server').that_subscribes_to('Anchor[neutron::service::begin]')
should contain_service('neutron-rpc-server').that_notifies('Anchor[neutron::service::end]')
end
should_not contain_class('neutron::db::sync')
should contain_service('neutron-server').with_name('neutron-server')
should contain_neutron_config('DEFAULT/api_workers').with_value(facts[:os_workers])
should contain_neutron_config('DEFAULT/rpc_workers').with_value(facts[:os_workers])
should contain_neutron_config('DEFAULT/rpc_response_max_timeout').with_value('<SERVICE DEFAULT>')
@ -79,7 +99,12 @@ describe 'neutron::server' do
end
it 'should not start/stop service' do
should contain_service('neutron-server').without_ensure
if platform_params.has_key?(:server_service)
should contain_service('neutron-server').without_ensure
else
should contain_service('neutron-api').without_ensure
should contain_service('neutron-rpc-server').without_ensure
end
end
end
@ -218,7 +243,11 @@ describe 'neutron::server' do
context 'when running neutron-api in wsgi' do
before :each do
params.merge!( :service_name => 'httpd' )
params.merge!(
:service_name => false,
:api_service_name => 'httpd',
:rpc_service_name => 'neutron-rpc-server',
)
end
let :pre_condition do
@ -230,11 +259,27 @@ describe 'neutron::server' do
end
it 'configures neutron-api service with Apache' do
should contain_service('neutron-server').with(
:ensure => 'stopped',
:name => platform_params[:server_service],
:enable => false,
:tag => ['neutron-service', 'neutron-db-sync-service'],
if platform_params.has_key?(:server_service)
should contain_service('neutron-server').with(
:ensure => 'stopped',
:name => platform_params[:server_service],
:enable => false,
:tag => ['neutron-service'],
)
else
should contain_service('neutron-api').with(
:ensure => 'stopped',
:name => platform_params[:api_service_name],
:enable => false,
:tag => ['neutron-service'],
)
end
should contain_service('neutron-rpc-server').with(
:ensure => 'running',
:name => 'neutron-rpc-server',
:enable => true,
:tag => ['neutron-service', 'neutron-db-sync-service'],
)
end
end
@ -331,13 +376,22 @@ describe 'neutron::server' do
let (:platform_params) do
case facts[:osfamily]
when 'Debian'
{
:server_package => 'neutron-server',
:server_service => 'neutron-server'
}
if facts[:operatingsystem] == 'Ubuntu'
{
:server_package => 'neutron-server',
:server_service => 'neutron-server',
:rpc_service_name => 'neutron-rpc-server',
}
else
{
:api_service_name => 'neutron-api',
:rpc_service_name => 'neutron-rpc-server',
}
end
when 'RedHat'
{
:server_service => 'neutron-server'
:server_service => 'neutron-server',
:rpc_service_name => 'neutron-rpc-server',
}
end
end