Skip to content

Commit

Permalink
Allow users to disable wsgi socket rotation (#801)
Browse files Browse the repository at this point in the history
The lp bug 1863232 introduced a new configuration option called
WSGISocketRotation which allows users to disable socket rotation on the apache
side. This patch will also allow setting this option on the charm side.

Other gerrit review links:
horizon: https://review.opendev.org/c/openstack/charm-openstack-dashboard/+/886373
cinder: https://review.opendev.org/c/openstack/charm-cinder/+/886356
keystone: https://review.opendev.org/c/openstack/charm-keystone/+/886377
ncc: https://review.opendev.org/c/openstack/charm-nova-cloud-controller/+/885836

Partial-Bug: 2021550
  • Loading branch information
zhhuabj authored Jul 5, 2023
1 parent 5478864 commit 996f241
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions charmhelpers/contrib/openstack/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,9 @@ def __init__(self, name=None, script=None, admin_script=None,

def __call__(self):
total_processes = _calculate_workers()
enable_wsgi_rotation = config('wsgi-rotation')
if enable_wsgi_rotation is None:
enable_wsgi_rotation = True
ctxt = {
"service_name": self.service_name,
"user": self.user,
Expand All @@ -1761,6 +1764,7 @@ def __call__(self):
"public_processes": int(math.ceil(self.public_process_weight *
total_processes)),
"threads": 1,
"wsgi_rotation": enable_wsgi_rotation,
}
return ctxt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Listen {{ admin_port }}
Listen {{ public_port }}
{% endif -%}

{% if wsgi_rotation -%}
WSGISocketRotation On
{% else -%}
WSGISocketRotation Off
{% endif -%}

{% if port -%}
<VirtualHost *:{{ port }}>
WSGIDaemonProcess {{ service_name }} processes={{ processes }} threads={{ threads }} user={{ user }} group={{ group }} \
Expand Down
10 changes: 8 additions & 2 deletions tests/contrib/openstack/test_os_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3569,7 +3569,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-rotation': True
})
_calculate_workers.return_value = 8
service_name = 'service-name'
script = '/usr/bin/script'
Expand All @@ -3586,13 +3588,16 @@ def test_wsgi_worker_config_context(self,
"admin_processes": 2,
"public_processes": 6,
"threads": 1,
"wsgi_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-rotation': False
})
_calculate_workers.return_value = 1
service_name = 'service-name'
script = '/usr/bin/script'
Expand All @@ -3613,6 +3618,7 @@ def test_wsgi_worker_config_context_user_and_group(self,
"admin_processes": 1,
"public_processes": 1,
"threads": 1,
"wsgi_rotation": False,
}
self.assertEqual(expect, ctxt())

Expand Down

0 comments on commit 996f241

Please sign in to comment.