From a93efae077aca83376ded931d453cae55155bccb Mon Sep 17 00:00:00 2001 From: Zhang Hua Date: Tue, 17 Oct 2023 18:04:58 +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: If1f41ae2c3048540f9bcace4bbb9d24200cfb427 --- charmhelpers/contrib/openstack/context.py | 4 ++++ .../contrib/openstack/templates/wsgi-openstack-api.conf | 6 ++++++ .../openstack/templates/wsgi-openstack-metadata.conf | 6 ++++++ charmhelpers/contrib/openstack/utils.py | 2 +- charmhelpers/contrib/storage/linux/ceph.py | 8 ++++++-- charmhelpers/fetch/snap.py | 2 +- config.yaml | 8 ++++++++ 7 files changed, 32 insertions(+), 4 deletions(-) diff --git a/charmhelpers/contrib/openstack/context.py b/charmhelpers/contrib/openstack/context.py index d894b6a..42f1503 100644 --- a/charmhelpers/contrib/openstack/context.py +++ b/charmhelpers/contrib/openstack/context.py @@ -1748,6 +1748,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, @@ -1761,6 +1764,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 6c4e37e..de5f603 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 6c4e37e..de5f603 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/contrib/openstack/utils.py b/charmhelpers/contrib/openstack/utils.py index 3d52eb1..83b6884 100644 --- a/charmhelpers/contrib/openstack/utils.py +++ b/charmhelpers/contrib/openstack/utils.py @@ -957,7 +957,7 @@ def os_requires_version(ostack_release, pkg): def wrap(f): @wraps(f) def wrapped_f(*args): - if os_release(pkg) < ostack_release: + if CompareOpenStackReleases(os_release(pkg)) < ostack_release: raise Exception("This hook is not supported on releases" " before %s" % ostack_release) f(*args) diff --git a/charmhelpers/contrib/storage/linux/ceph.py b/charmhelpers/contrib/storage/linux/ceph.py index 1b20b8f..2ff7a88 100644 --- a/charmhelpers/contrib/storage/linux/ceph.py +++ b/charmhelpers/contrib/storage/linux/ceph.py @@ -159,15 +159,19 @@ def get_osd_settings(relation_name): return _order_dict_by_key(osd_settings) -def send_application_name(relid=None): +def send_application_name(relid=None, app_name=None): """Send the application name down the relation. :param relid: Relation id to set application name in. :type relid: str + :param app_name: Application name to send in the relation. + :type app_name: str """ + if app_name is None: + app_name = application_name() relation_set( relation_id=relid, - relation_settings={'application-name': application_name()}) + relation_settings={'application-name': app_name}) def send_osd_settings(): diff --git a/charmhelpers/fetch/snap.py b/charmhelpers/fetch/snap.py index 36d6bce..231e4fd 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 3b42362..70052ce 100644 --- a/config.yaml +++ b/config.yaml @@ -285,3 +285,11 @@ options: The number of measures from same pollster to batch together for sending to the notification agent and then to the publisher. Set to 0 to disable. This config is only effective for OpenStack release Rocky or newer. + 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.