From c35faf4cbcd3ee7d4a069368be5c6655f22758fa Mon Sep 17 00:00:00 2001 From: James Page Date: Wed, 14 Mar 2018 17:42:56 +0000 Subject: [PATCH] Auto-configure WSGI worker processes Automatically configure WSGI worker processes inline with other charms using the worker-multiplier configuration option and the WSGI worker configuration context from charm-helpers. Change-Id: Ib8af4a5a54fcff13a05ba4f4094bf123d5282c4a --- config.yaml | 9 +++++++++ hooks/horizon_utils.py | 6 ++++-- templates/icehouse/openstack-dashboard.conf | 2 +- templates/newton/openstack-dashboard.conf | 2 +- templates/ocata/openstack-dashboard.conf | 2 +- templates/pike/openstack-dashboard.conf | 2 +- 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/config.yaml b/config.yaml index b3da5630..e9d747ef 100644 --- a/config.yaml +++ b/config.yaml @@ -348,3 +348,12 @@ options: . If not provided, leave the option unconfigured which enables all of the above. + worker-multiplier: + type: float + default: + description: | + The CPU core multiplier to use when configuring worker processes for + Horizon. By default, the number of workers for each daemon is set to + twice the number of CPU cores a service unit has. When deployed in + a LXD container, this default value will be capped to 4 workers + unless this configuration option is set. diff --git a/hooks/horizon_utils.py b/hooks/horizon_utils.py index c5014e76..0af36725 100644 --- a/hooks/horizon_utils.py +++ b/hooks/horizon_utils.py @@ -98,12 +98,14 @@ CONFIG_FILES = OrderedDict([ }), (APACHE_CONF, { 'hook_contexts': [horizon_contexts.HorizonContext(), - context.SyslogContext()], + context.SyslogContext(), + context.WSGIWorkerConfigContext()], 'services': ['apache2', 'memcached'], }), (APACHE_24_CONF, { 'hook_contexts': [horizon_contexts.HorizonContext(), - context.SyslogContext()], + context.SyslogContext(), + context.WSGIWorkerConfigContext()], 'services': ['apache2', 'memcached'], }), (APACHE_SSL, { diff --git a/templates/icehouse/openstack-dashboard.conf b/templates/icehouse/openstack-dashboard.conf index 634cddae..28a1dc03 100644 --- a/templates/icehouse/openstack-dashboard.conf +++ b/templates/icehouse/openstack-dashboard.conf @@ -1,5 +1,5 @@ WSGIScriptAlias {{ webroot }} /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi -WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10 +WSGIDaemonProcess horizon user=horizon group=horizon processes={{ processes }} threads=10 WSGIProcessGroup horizon Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/ Alias /horizon/static /usr/share/openstack-dashboard/openstack_dashboard/static/ diff --git a/templates/newton/openstack-dashboard.conf b/templates/newton/openstack-dashboard.conf index 634cddae..28a1dc03 100644 --- a/templates/newton/openstack-dashboard.conf +++ b/templates/newton/openstack-dashboard.conf @@ -1,5 +1,5 @@ WSGIScriptAlias {{ webroot }} /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi -WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10 +WSGIDaemonProcess horizon user=horizon group=horizon processes={{ processes }} threads=10 WSGIProcessGroup horizon Alias /static /usr/share/openstack-dashboard/openstack_dashboard/static/ Alias /horizon/static /usr/share/openstack-dashboard/openstack_dashboard/static/ diff --git a/templates/ocata/openstack-dashboard.conf b/templates/ocata/openstack-dashboard.conf index 81055d06..e22b3cfa 100644 --- a/templates/ocata/openstack-dashboard.conf +++ b/templates/ocata/openstack-dashboard.conf @@ -1,5 +1,5 @@ WSGIScriptAlias {{ webroot }} /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi -WSGIDaemonProcess horizon user=www-data group=www-data processes=3 threads=10 +WSGIDaemonProcess horizon user=www-data group=www-data processes={{ processes }} threads=10 WSGIProcessGroup horizon Alias /static /var/lib/openstack-dashboard/static/ Alias /horizon/static /var/lib/openstack-dashboard/static/ diff --git a/templates/pike/openstack-dashboard.conf b/templates/pike/openstack-dashboard.conf index 053625fd..99feddfb 100644 --- a/templates/pike/openstack-dashboard.conf +++ b/templates/pike/openstack-dashboard.conf @@ -1,5 +1,5 @@ WSGIScriptAlias {{ webroot }} /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi -WSGIDaemonProcess horizon user=horizon group=horizon processes=3 threads=10 +WSGIDaemonProcess horizon user=horizon group=horizon processes={{ processes }} threads=10 WSGIProcessGroup horizon Alias /static /var/lib/openstack-dashboard/static/ Alias /horizon/static /var/lib/openstack-dashboard/static/