From 2fe4d1e1e9c4b930d1b7f9386e7e928832d29d9a Mon Sep 17 00:00:00 2001 From: Zhang Hua Date: Fri, 3 Nov 2023 12:46:05 +0800 Subject: [PATCH] Support disabling apache wsgi socket rotation Bug LP 1863232 introduced a new Apache configuration option called WSGISocketRotation which allows users to disable wsgi socket rotation. This patch makes this configurable with a new wsgi-socket-rotation config option that defaults to the Apache default and can optionally be set to False. Closes-Bug: #2021550 Change-Id: Icd8dd674b6b5767a5db766dc1ba79bb216bbce3a --- charmhelpers/contrib/openstack/context.py | 4 ++++ .../contrib/openstack/templates/wsgi-openstack-api.conf | 6 ++++++ .../openstack/templates/wsgi-openstack-metadata.conf | 6 ++++++ charmhelpers/fetch/snap.py | 2 +- config.yaml | 8 ++++++++ test-requirements.txt | 4 ++++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/charmhelpers/contrib/openstack/context.py b/charmhelpers/contrib/openstack/context.py index 2c21ed35..1d37217c 100644 --- a/charmhelpers/contrib/openstack/context.py +++ b/charmhelpers/contrib/openstack/context.py @@ -1674,6 +1674,9 @@ class WSGIWorkerConfigContext(WorkerConfigContext): 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, @@ -1687,6 +1690,7 @@ class WSGIWorkerConfigContext(WorkerConfigContext): "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 6c4e37e4..de5f603f 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/charmhelpers/contrib/openstack/templates/wsgi-openstack-metadata.conf b/charmhelpers/contrib/openstack/templates/wsgi-openstack-metadata.conf index 6c4e37e4..de5f603f 100644 --- a/charmhelpers/contrib/openstack/templates/wsgi-openstack-metadata.conf +++ b/charmhelpers/contrib/openstack/templates/wsgi-openstack-metadata.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/charmhelpers/fetch/snap.py b/charmhelpers/fetch/snap.py index 36d6bce9..231e4fde 100644 --- a/charmhelpers/fetch/snap.py +++ b/charmhelpers/fetch/snap.py @@ -52,7 +52,7 @@ def _snap_exec(commands): :param commands: List commands :return: Integer exit code """ - assert type(commands) == list + assert type(commands) is list retry_count = 0 return_code = None diff --git a/config.yaml b/config.yaml index ba98db8c..f79b9dbb 100644 --- a/config.yaml +++ b/config.yaml @@ -428,3 +428,11 @@ options: Openstack mostly defaults to using public endpoints for internal communication between services. If set to True this option will configure services to use internal endpoints where possible. + wsgi-socket-rotation: + type: boolean + default: True + description: | + Allow users to disable Apache wsgi socket rotation. If not configured, + this option sets True as the default value, which is consistent with the + default value 'WSGISocketRotation On' in Apache. This option should be + used with caution. Please read the Apache doc page for more information. diff --git a/test-requirements.txt b/test-requirements.txt index 78b3c7d9..a9da8646 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -36,6 +36,10 @@ stevedore<1.31.0;python_version<'3.6' debtcollector<1.22.0;python_version<'3.6' oslo.utils<=3.41.0;python_version<'3.6' +# New openstacksdk versions depend on platformdirs>=3 which does not support +# python 3.6 +openstacksdk<1.6.0; python_version <= '3.6' + coverage>=4.5.2 pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking) git+https://github.com/openstack-charmers/zaza.git@stable/xena#egg=zaza