api: Prepare to remove nova_metadata_wsgi_enabled

The nova::api::nova_metadata_wsgi_enabled parameter has been deprecated
but in fact users have had to set the options to deploy nova API by
httpd and mod_wsgi.

This removes the logic to deploy api run by httpd and mod_wsgi along
with metadata api run by eventlet, so that we can remove the option
in the next cycle.

Change-Id: Ic28c6783d7e7ccebc0a18878155d02521f504091
This commit is contained in:
Takashi Kajinami 2023-11-13 01:51:29 +09:00
parent 1c2f147c2a
commit 3c81436a3a
3 changed files with 21 additions and 81 deletions

View File

@ -193,7 +193,7 @@ class nova::api(
$instance_list_cells_batch_fixed_size = $facts['os_service_default'],
$list_records_by_skipping_down_cells = $facts['os_service_default'],
# DEPRECATED PARAMETER
Boolean $nova_metadata_wsgi_enabled = false,
$nova_metadata_wsgi_enabled = undef,
$use_forwarded_for = undef,
) inherits nova::params {
@ -204,40 +204,26 @@ class nova::api(
include nova::availability_zone
include nova::pci
if !$nova_metadata_wsgi_enabled {
warning('Running nova metadata api via evenlet is deprecated and will be removed in Stein release.')
if $nova_metadata_wsgi_enabled != undef {
warning('The nova_metadata_wsgi_enabled parameter has been deprecated and has no effect')
}
if $use_forwarded_for != undef {
warning('The use_forwarded_for parameter has been deprecated.')
}
# enable metadata in eventlet if we do not run metadata via wsgi (nova::metadata)
if ('metadata' in $enabled_apis and $service_name == 'httpd' and !$nova_metadata_wsgi_enabled) {
$enable_metadata = true
} else {
$enable_metadata = false
}
# sanitize service_name and prepare DEFAULT/enabled_apis parameter
if $service_name == $::nova::params::api_service_name {
# if running evenlet, we use the original puppet parameter
# so people can enable custom service names and we keep backward compatibility.
$enabled_apis_real = $enabled_apis
$service_enabled = $enabled
} elsif $service_name == 'httpd' {
# when running wsgi, we want to enable metadata in eventlet if part of enabled_apis
# but only if we do not run metadata via wsgi (nova::metadata)
if $enable_metadata {
$enabled_apis_real = ['metadata']
$service_enabled = $enabled
} else {
# otherwise, set it to empty list
$enabled_apis_real = []
# if running wsgi for compute, and metadata disabled
# we don't need to enable nova-api service.
$service_enabled = false
nova_config {
'DEFAULT/enabled_apis': value => join(any2array($enabled_apis), ',');
}
$service_enabled = $enabled
} elsif $service_name == 'httpd' {
nova_config {
'DEFAULT/enabled_apis': ensure => absent;
}
$service_enabled = false
policy_rcd { 'nova-api':
ensure => present,
set_code => '101',
@ -272,7 +258,7 @@ as a standalone service, or httpd for being run by a httpd server")
}
}
if !$nova_metadata_wsgi_enabled {
if $service_name != 'httpd' {
nova_config {
'DEFAULT/metadata_workers': value => $metadata_workers;
'DEFAULT/metadata_listen': value => $metadata_listen;
@ -292,7 +278,6 @@ as a standalone service, or httpd for being run by a httpd server")
}
nova_config {
'DEFAULT/enabled_apis': value => join($enabled_apis_real, ',');
'wsgi/api_paste_config': value => $api_paste_config;
'DEFAULT/osapi_compute_listen': value => $api_bind_address;
'DEFAULT/osapi_compute_listen_port': value => $osapi_compute_listen_port;

View File

@ -0,0 +1,6 @@
---
upgrade:
- |
The ``nova::api::nova_metadata_wsgi_enabled`` parameter has no effect now.
When nova API service is deployed using httpd and mod_wsgi, nova-api
service is no longer started. Use httpd + mod_wsgi to run metadata api.

View File

@ -156,62 +156,10 @@ describe 'nova::api' do
it { is_expected.to_not contain_service('nova-api') }
end
context 'when running nova API in wsgi compute, and enabling metadata' do
before do
params.merge!({ :service_name => 'httpd' })
end
let :pre_condition do
"include apache
include nova
class { 'nova::keystone::authtoken':
password => 'a_big_secret',
}"
end
it 'enable nova API service' do
is_expected.to contain_service('nova-api').with(
:ensure => 'running',
:name => platform_params[:nova_api_service],
:enable => true,
:tag => 'nova-service',
)
end
it 'enable metadata in evenlet configuration' do
is_expected.to contain_nova_config('DEFAULT/enabled_apis').with_value('metadata')
end
end
context 'when running nova API in wsgi for compute, and disabling metadata' do
context 'when running nova API in wsgi for compute' do
before do
params.merge!({
:service_name => 'httpd',
:enabled_apis => ['osapi_compute'] })
end
let :pre_condition do
"include apache
include nova
class { 'nova::keystone::authtoken':
password => 'a_big_secret',
}"
end
it 'disable nova API service' do
is_expected.to contain_service('nova-api').with(
:ensure => 'stopped',
:name => platform_params[:nova_api_service],
:enable => false,
:tag => 'nova-service',
)
end
end
context 'when running nova API in wsgi for compute, and metadata in wsgi' do
before do
params.merge!({
:service_name => 'httpd',
:nova_metadata_wsgi_enabled => true
})
end
@ -230,6 +178,7 @@ describe 'nova::api' do
:enable => false,
:tag => 'nova-service',
)
is_expected.to contain_nova_config('DEFAULT/enabled_apis').with_ensure('absent')
is_expected.to contain_nova_config('DEFAULT/metadata_workers').with_ensure('absent')
is_expected.to contain_nova_config('DEFAULT/metadata_listen').with_ensure('absent')
is_expected.to contain_nova_config('DEFAULT/metadata_listen_port').with_ensure('absent')