From 5c14e86d37681bb447b2a663c95d6c85ef4f1043 Mon Sep 17 00:00:00 2001 From: David Moreau-Simard Date: Fri, 20 Oct 2017 18:24:25 -0400 Subject: [PATCH] Add support for installing ARA wsgi middleware for sqlite databases ARA is going to bundle a WSGI middleware that allows an operator to route an URL (by default ^.*/ara-report) to the ARA web application. This URL is expected to contain an 'ansible.sqlite' database that would have been uploaded as part of log collection. There are no static files generated as part of this process. The web application reads directly from the database. It is meant to avoid having to generate a static report for each job which does not scale very well for the amount of jobs we are running. For more details, see this code review in ARA [1]. [1]: https://review.openstack.org/#/c/511992/ Change-Id: I3b10c93b4902a9b45e23c227863e472697f662ef --- contrib/log_server_data.yaml | 4 ++-- contrib/log_server_site.pp | 1 + manifests/logserver.pp | 20 ++++++++++++++++++++ templates/logs-dev.vhost.erb | 22 ++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/contrib/log_server_data.yaml b/contrib/log_server_data.yaml index 27fed0c..8f4f997 100644 --- a/contrib/log_server_data.yaml +++ b/contrib/log_server_data.yaml @@ -1,11 +1,11 @@ # See parameter documetation inside ../manifests/single_node_ci.pp # Fields commented out have reasonable default values domain: your-domain.example.com -jenkins_ssh_public_key: your-jenkins-public-key-no-whitespace +jenkins_ssh_public_key: your-jenkins-public-key-no-whitespace +ara_middleware: false #swift_authurl: #swift_user: #swift_key: #swift_tenant_name: #swift_region_name: #swift_default_container: - diff --git a/contrib/log_server_site.pp b/contrib/log_server_site.pp index df7ccf3..bfd4258 100644 --- a/contrib/log_server_site.pp +++ b/contrib/log_server_site.pp @@ -23,6 +23,7 @@ node default { class { '::openstackci::logserver': domain => hiera('domain'), jenkins_ssh_key => hiera('jenkins_ssh_public_key'), + ara_middleware => hiera('ara_middleware', false), swift_authurl => hiera('swift_authurl', ''), swift_user => hiera('swift_user', ''), swift_key => hiera('swift_key', ''), diff --git a/manifests/logserver.pp b/manifests/logserver.pp index 3968d44..8746813 100644 --- a/manifests/logserver.pp +++ b/manifests/logserver.pp @@ -13,11 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. +# [*ara_middleware*] +# (optional) Whether or not to set up the ARA database middleware +# Defaults to false. +# # == Class: openstackci::logserver # class openstackci::logserver ( $domain, $jenkins_ssh_key, + $ara_middleware = false, + $ara_middleware_tmpdir_max_age = 3600, + $ara_middleware_database_directory = 'ara-report', $swift_authurl = '', $swift_user = '', $swift_key = '', @@ -196,4 +203,17 @@ class openstackci::logserver ( require => File['/usr/local/sbin/log_archive_maintenance.sh'], } + if $ara_middleware { + package { 'ara': + ensure => 'latest', + provider => 'openstack_pip', + require => [ + Package['build-essential'], + Package['python-dev'], + Package['libffi-dev'], + Package['libssl-dev'] + ], + notify => Service['httpd'] + } + } } diff --git a/templates/logs-dev.vhost.erb b/templates/logs-dev.vhost.erb index c1bee0b..07cbaa9 100644 --- a/templates/logs-dev.vhost.erb +++ b/templates/logs-dev.vhost.erb @@ -60,6 +60,28 @@ NameVirtualHost <%= @vhost_name %>:<%= @port %> <% end -%> RewriteEngine On +<% if @ara_middleware -%> + + + Allow from all + Satisfy Any + + + # Redirect .*/<%= @ara_middleware_database_directory %> to the ARA sqlite wsgi middleware + # This middleware automatically loads the ARA web application with the + # database located at .*/<%= @ara_middleware_database_directory %>/ansible.sqlite. + SetEnv ARA_WSGI_TMPDIR_MAX_AGE <%= @ara_middleware_tmpdir_max_age %> + SetEnv ARA_WSGI_LOG_ROOT <%= @docroot %> + SetEnv ARA_WSGI_DATABASE_DIRECTORY <%= @ara_middleware_database_directory %> + + WSGIScriptAliasMatch ^.*/<%= @ara_middleware_database_directory %> /usr/local/bin/ara-wsgi-sqlite + + # Everything beyond this point is rewritten to htmlify. + # Make sure we don't do that for dynamic ARA reports. + RewriteCond %{REQUEST_URI} ^.*/<%= @ara_middleware_database_directory %> [NC] + RewriteRule .* - [L] +<% end -%> + # If the specified file does not exist, look if there is a gzipped version # If there is, serve that one instead RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f