diff --git a/charmhelpers/contrib/openstack/context.py b/charmhelpers/contrib/openstack/context.py index 6ef1994bf..5b8b284a5 100644 --- a/charmhelpers/contrib/openstack/context.py +++ b/charmhelpers/contrib/openstack/context.py @@ -1665,6 +1665,9 @@ def __init__(self, name=None, script=None, admin_script=None, def __call__(self): total_processes = _calculate_workers() + enable_wsgi_socket_rotation = config('wsgi-socket-rotation') + if enable_wsgi_socket_rotation is None: + enable_wsgi_socket_rotation = True ctxt = { "service_name": self.service_name, "user": self.user, @@ -1678,6 +1681,7 @@ def __call__(self): "public_processes": int(math.ceil(self.public_process_weight * total_processes)), "threads": 1, + "wsgi_socket_rotation": enable_wsgi_socket_rotation, } return ctxt diff --git a/charmhelpers/contrib/openstack/templates/wsgi-openstack-api.conf b/charmhelpers/contrib/openstack/templates/wsgi-openstack-api.conf index 6c4e37e40..de5f603fc 100644 --- a/charmhelpers/contrib/openstack/templates/wsgi-openstack-api.conf +++ b/charmhelpers/contrib/openstack/templates/wsgi-openstack-api.conf @@ -12,6 +12,12 @@ Listen {{ admin_port }} Listen {{ public_port }} {% endif -%} +{% if wsgi_socket_rotation -%} +WSGISocketRotation On +{% else -%} +WSGISocketRotation Off +{% endif -%} + {% if port -%} WSGIDaemonProcess {{ service_name }} processes={{ processes }} threads={{ threads }} user={{ user }} group={{ group }} \ diff --git a/tests/contrib/openstack/test_os_contexts.py b/tests/contrib/openstack/test_os_contexts.py index 63eb76634..97b0a6f61 100644 --- a/tests/contrib/openstack/test_os_contexts.py +++ b/tests/contrib/openstack/test_os_contexts.py @@ -3288,7 +3288,9 @@ def test_loglevel_context_unset(self): @patch.object(context, '_calculate_workers') def test_wsgi_worker_config_context(self, _calculate_workers): - self.config.return_value = 2 # worker-multiplier=2 + self.config.side_effect = fake_config({ + 'worker-multiplier': 2, 'non-defined-wsgi-socket-rotation': True + }) _calculate_workers.return_value = 8 service_name = 'service-name' script = '/usr/bin/script' @@ -3305,13 +3307,16 @@ def test_wsgi_worker_config_context(self, "admin_processes": 2, "public_processes": 6, "threads": 1, + "wsgi_socket_rotation": True, } self.assertEqual(expect, ctxt()) @patch.object(context, '_calculate_workers') def test_wsgi_worker_config_context_user_and_group(self, _calculate_workers): - self.config.return_value = 1 + self.config.side_effect = fake_config({ + 'worker-multiplier': 1, 'wsgi-socket-rotation': False + }) _calculate_workers.return_value = 1 service_name = 'service-name' script = '/usr/bin/script' @@ -3332,6 +3337,7 @@ def test_wsgi_worker_config_context_user_and_group(self, "admin_processes": 1, "public_processes": 1, "threads": 1, + "wsgi_socket_rotation": False, } self.assertEqual(expect, ctxt())