Allow to activate WSGIImportScript option
This should prevent slow loading on the first request, especially annoying when this first request is done by a healthcheck launched by an inflight validation. This patch is a reaction to the whole issue raised by the new nova inflight validations[1], followed by some discussions in order to get a faster application loading. [1] https://review.opendev.org/#/q/status:merged+project:openstack/tripleo-heat-templates+branch:master+topic:bug/1842687 Related-Bug: #1843555 Change-Id: I27e37e30823c4312d9d7a93f18fe0f930ce70c49
This commit is contained in:
@@ -134,6 +134,25 @@
|
|||||||
# WSGIChunkedRequest option in the vhost.
|
# WSGIChunkedRequest option in the vhost.
|
||||||
# Defaults to undef
|
# Defaults to undef
|
||||||
#
|
#
|
||||||
|
# [*set_wsgi_import_script*]
|
||||||
|
# (Optional) Enable WSGIImportScript.
|
||||||
|
# Defaults to false
|
||||||
|
#
|
||||||
|
# [*wsgi_import_script*]
|
||||||
|
# (Optional) WSGIImportScript path.
|
||||||
|
# Defaults to undef
|
||||||
|
# If not set and set_wsgi_import_script is true, defaults to the WSGI
|
||||||
|
# application module path
|
||||||
|
#
|
||||||
|
# [*wsgi_import_script_options*]
|
||||||
|
# (Optional) Sets WSGIImportScript options.
|
||||||
|
# Defaults to undef
|
||||||
|
# If not set and set_wsgi_import_script is true, push a dict as follow:
|
||||||
|
# {
|
||||||
|
# process-group => $wsgi_daemon_process,
|
||||||
|
# application-group => $wsgi_application_group,
|
||||||
|
# }
|
||||||
|
#
|
||||||
# [*headers*]
|
# [*headers*]
|
||||||
# (Optional) Headers for the vhost.
|
# (Optional) Headers for the vhost.
|
||||||
# Defaults to undef
|
# Defaults to undef
|
||||||
@@ -224,6 +243,9 @@ define openstacklib::wsgi::apache (
|
|||||||
$wsgi_application_group = '%{GLOBAL}',
|
$wsgi_application_group = '%{GLOBAL}',
|
||||||
$wsgi_pass_authorization = undef,
|
$wsgi_pass_authorization = undef,
|
||||||
$wsgi_chunked_request = undef,
|
$wsgi_chunked_request = undef,
|
||||||
|
$set_wsgi_import_script = false,
|
||||||
|
$wsgi_import_script = undef,
|
||||||
|
$wsgi_import_script_options = undef,
|
||||||
$headers = undef,
|
$headers = undef,
|
||||||
$custom_wsgi_process_options = {},
|
$custom_wsgi_process_options = {},
|
||||||
$custom_wsgi_script_aliases = undef,
|
$custom_wsgi_script_aliases = undef,
|
||||||
@@ -285,6 +307,27 @@ define openstacklib::wsgi::apache (
|
|||||||
$wsgi_script_aliases_real = $wsgi_script_aliases_default
|
$wsgi_script_aliases_real = $wsgi_script_aliases_default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Sets WSGIImportScript related options
|
||||||
|
if $set_wsgi_import_script {
|
||||||
|
if $wsgi_import_script {
|
||||||
|
$wsgi_import_script_real = $wsgi_import_script
|
||||||
|
} else {
|
||||||
|
$wsgi_import_script_real = $wsgi_script_aliases_real[$path_real]
|
||||||
|
}
|
||||||
|
if $wsgi_import_script_options {
|
||||||
|
$wsgi_import_script_options_real = $wsgi_import_script_options
|
||||||
|
} else {
|
||||||
|
$wsgi_import_script_options_real = {
|
||||||
|
process-group => $wsgi_daemon_process,
|
||||||
|
application-group => $wsgi_application_group,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$wsgi_import_script_real = undef
|
||||||
|
$wsgi_import_script_options_real = undef
|
||||||
|
}
|
||||||
|
# End of WSGIImportScript related options
|
||||||
|
|
||||||
::apache::vhost { $service_name:
|
::apache::vhost { $service_name:
|
||||||
ensure => 'present',
|
ensure => 'present',
|
||||||
servername => $servername,
|
servername => $servername,
|
||||||
@@ -310,6 +353,8 @@ define openstacklib::wsgi::apache (
|
|||||||
wsgi_application_group => $wsgi_application_group,
|
wsgi_application_group => $wsgi_application_group,
|
||||||
wsgi_pass_authorization => $wsgi_pass_authorization,
|
wsgi_pass_authorization => $wsgi_pass_authorization,
|
||||||
wsgi_chunked_request => $wsgi_chunked_request,
|
wsgi_chunked_request => $wsgi_chunked_request,
|
||||||
|
wsgi_import_script => $wsgi_import_script_real,
|
||||||
|
wsgi_import_script_options => $wsgi_import_script_options_real,
|
||||||
headers => $headers,
|
headers => $headers,
|
||||||
custom_fragment => $vhost_custom_fragment,
|
custom_fragment => $vhost_custom_fragment,
|
||||||
allow_encoded_slashes => $allow_encoded_slashes,
|
allow_encoded_slashes => $allow_encoded_slashes,
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add new WSGI related options that should allow faster application startup
|
||||||
|
and loading.
|
@@ -197,6 +197,53 @@ describe 'openstacklib::wsgi::apache' do
|
|||||||
|
|
||||||
it { should contain_apache__vhost('keystone_wsgi').with_port(params[:bind_port]) }
|
it { should contain_apache__vhost('keystone_wsgi').with_port(params[:bind_port]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with set_wsgi_import_script enabled' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:bind_port => 5000,
|
||||||
|
:group => 'keystone',
|
||||||
|
:ssl => true,
|
||||||
|
:user => 'keystone',
|
||||||
|
:wsgi_script_dir => '/var/www/cgi-bin/keystone',
|
||||||
|
:wsgi_script_file => 'main',
|
||||||
|
:wsgi_script_source => '/usr/share/keystone/keystone.wsgi',
|
||||||
|
:set_wsgi_import_script => true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
it { should contain_apache__vhost('keystone_wsgi').with(
|
||||||
|
:wsgi_import_script_options => {
|
||||||
|
'process-group' => 'keystone_wsgi',
|
||||||
|
'application-group' => '%{GLOBAL}',
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
end
|
||||||
|
context 'with custom wsgi_import_script and options' do
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:bind_port => 5000,
|
||||||
|
:group => 'keystone',
|
||||||
|
:ssl => true,
|
||||||
|
:user => 'keystone',
|
||||||
|
:wsgi_script_dir => '/var/www/cgi-bin/keystone',
|
||||||
|
:wsgi_script_file => 'main',
|
||||||
|
:wsgi_script_source => '/usr/share/keystone/keystone.wsgi',
|
||||||
|
:set_wsgi_import_script => true,
|
||||||
|
:wsgi_import_script => '/foo/bar',
|
||||||
|
:wsgi_import_script_options => {
|
||||||
|
'process-group' => 'foo',
|
||||||
|
'application-group' => 'bar',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
it { should contain_apache__vhost('keystone_wsgi').with(
|
||||||
|
:wsgi_import_script => '/foo/bar',
|
||||||
|
:wsgi_import_script_options => {
|
||||||
|
'process-group' => 'foo',
|
||||||
|
'application-group' => 'bar',
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
on_supported_os({
|
on_supported_os({
|
||||||
|
Reference in New Issue
Block a user