Skip to content

Commit 2a29211

Browse files
committed
Add wsgi module to cloudkitty
Changes in python packaging tooling mean that the wsgi_scripts functionality via PBR may not longer function. This patch switches cloudkitty from using the PBR wsgi_scripts method to using a new wsgi module that provides the same behavior as the generated wsgi scripts provided. A related devstack patch enables devstack to setup uWSGI to use the new module path instead of the generated wsgi scripts. For more details see the proposed OpenStack goal [1]. Make grenade job non-voting until backport to stable/2025.1. [1] https://review.opendev.org/c/openstack/governance/+/902807 Change-Id: Id38cfa97699f01be89b37a9ee7a9e3253925e187
1 parent 761b51e commit 2a29211

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed

.zuul.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@
201201
- cloudkitty-tempest-full-ipv6-only
202202
- cloudkitty-tox-bandit:
203203
voting: false
204-
- cloudkitty-grenade-job
204+
- cloudkitty-grenade-job:
205+
voting: false
205206
gate:
206207
jobs:
207208
- cloudkitty-tempest-full-v2-storage-influxdb
@@ -211,4 +212,3 @@
211212
- cloudkitty-tempest-full-v2-storage-opensearch
212213
- cloudkitty-tempest-full-v1-storage-sqlalchemy
213214
- cloudkitty-tempest-full-ipv6-only
214-
- cloudkitty-grenade-job

cloudkitty/wsgi/__init__.py

Whitespace-only changes.

cloudkitty/wsgi/api.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
"""WSGI application entry-point for the CloudKitty API."""
14+
15+
import threading
16+
17+
from cloudkitty.api import app
18+
19+
application = None
20+
21+
lock = threading.Lock()
22+
with lock:
23+
if application is None:
24+
application = app.build_wsgi_app()

devstack/plugin.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if [[ -d $CLOUDKITTY_DIR/bin ]]; then
3737
else
3838
CLOUDKITTY_BIN_DIR=$(get_python_exec_prefix)
3939
fi
40-
CLOUDKITTY_UWSGI=$CLOUDKITTY_BIN_DIR/cloudkitty-api
40+
CLOUDKITTY_UWSGI=cloudkitty.wsgi.api:application
4141
if [ ${CLOUDKITTY_USE_UWSGI,,} == 'true' ]; then
4242
CLOUDKITTY_ENDPOINT=$CLOUDKITTY_SERVICE_PROTOCOL://$CLOUDKITTY_SERVICE_HOST/rating
4343
else
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
features:
3+
- |
4+
A new module, ``cloudkitty.wsgi``, has been added as a place to gather WSGI
5+
``application`` objects. This is intended to ease deployment by providing a
6+
consistent location for these objects. For example, if using uWSGI then
7+
instead of:
8+
9+
.. code-block:: ini
10+
11+
[uwsgi]
12+
wsgi-file = /bin/cloudkitty-api
13+
14+
You can now use:
15+
16+
.. code-block:: ini
17+
18+
[uwsgi]
19+
module = cloudkitty.wsgi.api:application
20+
21+
This also simplifies deployment with other WSGI servers that expect module
22+
paths such as gunicorn.
23+
upgrade:
24+
- |
25+
The WSGI script ``cloudkitty-api`` has been removed. Deployment tooling
26+
should instead reference the Python module path for the wsgi module in
27+
CloudKitty, ``cloudkitty.wsgi.api:application`` if their chosen WSGI server
28+
supports this (gunicorn, uWSGI, etc.) or implement a .wsgi script
29+
themselves if not (mod_wsgi).

0 commit comments

Comments
 (0)