Manage oslo_middleware/max_request_body_size

So that we can increase it from the default 114688

Useful in case for example the OS-Federation mapping is too large.

If this limit is breached nova will return a 413 Entity Too Large
and not log anything to nova.log.

Change-Id: I772046f81fe5570a68512c2607ca9cbf8b1fe8c7
Closes-Bug: #1835161
This commit is contained in:
ZhongShengping 2019-07-04 11:34:44 +08:00
parent 919409a7b1
commit bb4afe7d3d
5 changed files with 48 additions and 25 deletions

View File

@ -85,6 +85,10 @@
# middleware should parse the proxy headers or not.(boolean value)
# Defaults to $::os_service_default
#
# [*max_request_body_size*]
# (Optional) Set max request body size
# Defaults to $::os_service_default.
#
# [*validate*]
# (optional) Whether to validate the service is working after any service refreshes
# Defaults to false
@ -196,6 +200,7 @@ class nova::api(
$instance_name_template = undef,
$service_name = $::nova::params::api_service_name,
$enable_proxy_headers_parsing = $::os_service_default,
$max_request_body_size = $::os_service_default,
$max_limit = $::os_service_default,
$compute_link_prefix = $::os_service_default,
$glance_link_prefix = $::os_service_default,
@ -295,6 +300,7 @@ as a standalone service, or httpd for being run by a httpd server")
oslo::middleware {'nova_config':
enable_proxy_headers_parsing => $enable_proxy_headers_parsing,
max_request_body_size => $max_request_body_size,
}
}

View File

@ -13,6 +13,10 @@
# middleware should parse the proxy headers or not.(boolean value)
# Defaults to $::os_service_default
#
# [*max_request_body_size*]
# (Optional) Set max request body size
# Defaults to $::os_service_default.
#
# [*metadata_cache_expiration*]
# (optional) This option is the time (in seconds) to cache metadata.
# Defaults to $::os_service_default
@ -42,6 +46,7 @@
class nova::metadata(
$neutron_metadata_proxy_shared_secret = undef,
$enable_proxy_headers_parsing = $::os_service_default,
$max_request_body_size = $::os_service_default,
$metadata_cache_expiration = $::os_service_default,
$local_metadata_per_cell = $::os_service_default,
$dhcp_domain = $::os_service_default,
@ -75,6 +80,7 @@ class nova::metadata(
oslo::middleware {'nova_config':
enable_proxy_headers_parsing => $enable_proxy_headers_parsing,
max_request_body_size => $max_request_body_size,
}
if ($neutron_metadata_proxy_shared_secret){

View File

@ -0,0 +1,5 @@
---
features:
- |
Add support to configure `[oslo_middleware]/max_request_body_size` with
`$max_request_body_size`.

View File

@ -54,6 +54,7 @@ describe 'nova::api' do
is_expected.to contain_nova_config('DEFAULT/metadata_workers').with('value' => '5')
is_expected.to contain_oslo__middleware('nova_config').with(
:enable_proxy_headers_parsing => '<SERVICE DEFAULT>',
:max_request_body_size => '<SERVICE DEFAULT>',
)
is_expected.to contain_nova_config('api/max_limit').with('value' => '<SERVICE DEFAULT>')
is_expected.to contain_nova_config('api/compute_link_prefix').with('value' => '<SERVICE DEFAULT>')
@ -70,26 +71,27 @@ describe 'nova::api' do
context 'with overridden parameters' do
before do
params.merge!({
:enabled => false,
:ensure_package => '2012.1-2',
:api_bind_address => '192.168.56.210',
:metadata_listen => '127.0.0.1',
:metadata_listen_port => 8875,
:osapi_compute_listen_port => 8874,
:use_forwarded_for => false,
:ratelimits => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)',
:osapi_compute_workers => 1,
:metadata_workers => 2,
:enable_proxy_headers_parsing => true,
:max_limit => 1000,
:compute_link_prefix => 'https://10.0.0.1:7777/',
:glance_link_prefix => 'https://10.0.0.1:6666/',
:hide_server_address_states => 'building',
:allow_instance_snapshots => true,
:enable_network_quota => false,
:enable_instance_password => true,
:password_length => 12,
:allow_resize_to_same_host => true,
:enabled => false,
:ensure_package => '2012.1-2',
:api_bind_address => '192.168.56.210',
:metadata_listen => '127.0.0.1',
:metadata_listen_port => 8875,
:osapi_compute_listen_port => 8874,
:use_forwarded_for => false,
:ratelimits => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)',
:osapi_compute_workers => 1,
:metadata_workers => 2,
:enable_proxy_headers_parsing => true,
:max_request_body_size => '102400',
:max_limit => 1000,
:compute_link_prefix => 'https://10.0.0.1:7777/',
:glance_link_prefix => 'https://10.0.0.1:6666/',
:hide_server_address_states => 'building',
:allow_instance_snapshots => true,
:enable_network_quota => false,
:enable_instance_password => true,
:password_length => 12,
:allow_resize_to_same_host => true,
})
end
@ -121,6 +123,7 @@ describe 'nova::api' do
is_expected.to contain_nova_config('api/glance_link_prefix').with('value' => 'https://10.0.0.1:6666/')
is_expected.to contain_oslo__middleware('nova_config').with(
:enable_proxy_headers_parsing => true,
:max_request_body_size => '102400',
)
is_expected.to contain_nova_config('api/hide_server_address_states').with('value' => 'building')
is_expected.to contain_nova_config('api/allow_instance_snapshots').with('value' => true)

View File

@ -23,6 +23,7 @@ describe 'nova::metadata' do
is_expected.to contain_nova_config('api/metadata_cache_expiration').with('value' => '<SERVICE DEFAULT>')
is_expected.to contain_oslo__middleware('nova_config').with(
:enable_proxy_headers_parsing => '<SERVICE DEFAULT>',
:max_request_body_size => '<SERVICE DEFAULT>',
)
is_expected.to contain_nova_config('api/metadata_cache_expiration').with('value' => '<SERVICE DEFAULT>')
is_expected.to contain_nova_config('api/local_metadata_per_cell').with('value' => '<SERVICE DEFAULT>')
@ -38,11 +39,12 @@ describe 'nova::metadata' do
context 'with overridden parameters' do
before do
params.merge!({
:neutron_metadata_proxy_shared_secret => 'secrete',
:enable_proxy_headers_parsing => true,
:local_metadata_per_cell => true,
:metadata_cache_expiration => 15,
:dhcp_domain => 'foo',
:neutron_metadata_proxy_shared_secret => 'secrete',
:enable_proxy_headers_parsing => true,
:max_request_body_size => '102400',
:local_metadata_per_cell => true,
:metadata_cache_expiration => 15,
:dhcp_domain => 'foo',
})
end
@ -54,6 +56,7 @@ describe 'nova::metadata' do
is_expected.to contain_nova_config('neutron/metadata_proxy_shared_secret').with('value' => 'secrete').with_secret(true)
is_expected.to contain_oslo__middleware('nova_config').with(
:enable_proxy_headers_parsing => true,
:max_request_body_size => '102400',
)
end
end