From e6d83dfcf729fff333cfc5b700c62efb8aa4aebd Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Wed, 6 Dec 2023 21:53:18 +0000 Subject: [PATCH] Add wsgi module to Designate and remove wsgi script Changes in python packaging tooling mean that the wsgi_scripts functionality via PBR may not longer function. This patch switches Designate 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. This also aligns Designate to a new proposed OpenStack goal[1]. [1] https://review.opendev.org/c/openstack/governance/+/902807 In order to make the CI work, this patch was merged with: zuul: Drop centos9 and make grenade non-voting The requirements repo has dropped upper-constraints for python3.9, so the centos9-based jobs are no longer working on master, let's drop them. Also the grenade jobs are broken due to the referenced bug, make them temporarily non-voting, so that we can merge the fix[0] on master first, backport it, and then re-enable them. [0] https://review.opendev.org/c/openstack/designate/+/902846 Related-Bug: 2109577 Depends-On: https://review.opendev.org/c/openstack/devstack/+/902758 Change-Id: If90056ae1de4a6a3557fc870497e6233088bfb02 --- .zuul.yaml | 27 ++--------------- designate/wsgi/__init__.py | 0 designate/wsgi/api.py | 24 +++++++++++++++ devstack/lib/wsgi | 2 +- devstack/settings | 2 +- .../remove-wsgi-scripts-d848069ac50cf062.yaml | 29 +++++++++++++++++++ setup.cfg | 3 -- 7 files changed, 57 insertions(+), 30 deletions(-) create mode 100644 designate/wsgi/__init__.py create mode 100644 designate/wsgi/api.py create mode 100644 releasenotes/notes/remove-wsgi-scripts-d848069ac50cf062.yaml diff --git a/.zuul.yaml b/.zuul.yaml index 08b671d61..ce329ec1e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -51,16 +51,6 @@ post-run: playbooks/designate-bind9/post.yaml parent: designate-base -- job: - name: designate-bind9-centos9stream-fips - parent: designate-bind9 - nodeset: devstack-single-node-centos-9-stream - description: | - Functional testing for a FIPS enabled Centos 9 stream system - pre-run: playbooks/enable-fips.yaml - vars: - nslookup_target: 'opendev.org' - - job: name: designate-bind9-keystone-old-default-roles post-run: playbooks/designate-bind9/post.yaml @@ -83,15 +73,6 @@ enforce_scope: designate: False -- job: - name: designate-bind9-centos-9-stream - parent: designate-bind9 - nodeset: devstack-single-node-centos-9-stream - vars: - devstack_localrc: - DESIGNATE_COORDINATION_URL: "etcd3+http://{{ hostvars['controller']['nodepool']['private_ipv4'] }}:2379?api_version=v3" - - - job: name: designate-bind9-catalog-zones parent: designate-bind9 @@ -218,14 +199,11 @@ check: jobs: - designate-bind9 - - designate-bind9-centos9stream-fips: - voting: false - - designate-bind9-centos-9-stream: - voting: false - designate-bind9-keystone-old-default-roles - designate-pdns4 - designate-grenade-bind9 - - designate-grenade-pdns4 + - designate-grenade-pdns4: + voting: false - designate-grenade-bind9-skip-level - designate-grenade-pdns4-skip-level - designate-ipv6-only-pdns4 @@ -236,7 +214,6 @@ - designate-bind9 - designate-bind9-keystone-old-default-roles - designate-pdns4 - - designate-grenade-pdns4 - designate-grenade-pdns4-skip-level - designate-ipv6-only-pdns4 - designate-ipv6-only-bind9 diff --git a/designate/wsgi/__init__.py b/designate/wsgi/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/designate/wsgi/api.py b/designate/wsgi/api.py new file mode 100644 index 000000000..b083f1d29 --- /dev/null +++ b/designate/wsgi/api.py @@ -0,0 +1,24 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""WSGI application entry-point for the Designate API.""" + +import threading + +from designate.api import wsgi + +application = None + +lock = threading.Lock() +with lock: + if application is None: + application = wsgi.init_application() diff --git a/devstack/lib/wsgi b/devstack/lib/wsgi index e16a914eb..661e7acb5 100644 --- a/devstack/lib/wsgi +++ b/devstack/lib/wsgi @@ -1,7 +1,7 @@ #!/usr/bin/env bash function designate_configure_uwsgi { - write_uwsgi_config "$DESIGNATE_UWSGI_CONF" "$DESIGNATE_UWSGI" "/dns" + write_uwsgi_config "$DESIGNATE_UWSGI_CONF" "$DESIGNATE_UWSGI" "/dns" "" "designate-api-wsgi" # We are using the http transport to work around an issue with # broken connections when using the uwsgi protocol of a local socket diff --git a/devstack/settings b/devstack/settings index 3f541a2fd..5c0731127 100644 --- a/devstack/settings +++ b/devstack/settings @@ -60,7 +60,7 @@ DESIGNATE_ROOTWRAP_CONF=$DESIGNATE_CONF_DIR/rootwrap.conf DESIGNATE_APIPASTE_CONF=$DESIGNATE_CONF_DIR/api-paste.ini DESIGNATE_PLUGINS=$DESIGNATE_DIR/devstack/designate_plugins -DESIGNATE_UWSGI=$DESIGNATE_BIN_DIR/designate-api-wsgi +DESIGNATE_UWSGI=designate.wsgi.api:application DESIGNATE_UWSGI_CONF=$DESIGNATE_CONF_DIR/designate-api-uwsgi.ini # Default repositories diff --git a/releasenotes/notes/remove-wsgi-scripts-d848069ac50cf062.yaml b/releasenotes/notes/remove-wsgi-scripts-d848069ac50cf062.yaml new file mode 100644 index 000000000..e010683fd --- /dev/null +++ b/releasenotes/notes/remove-wsgi-scripts-d848069ac50cf062.yaml @@ -0,0 +1,29 @@ +--- +features: + - | + A new module, ``designate.wsgi``, has been added as a place to gather WSGI + ``application`` objects. This is intended to ease deployment by providing + a consistent location for these objects. For example, if using uWSGI then + instead of: + + .. code-block:: ini + + [uwsgi] + wsgi-file = /bin/designate-api-wsgi + + You can now use: + + .. code-block:: ini + + [uwsgi] + module = designate.wsgi.api:application + + This also simplifies deployment with other WSGI servers that expect module + paths such as gunicorn. +upgrade: + - | + The WSGI script ``designate-api-wsgi`` has been removed. Deployment tooling + should instead reference the Python module path for the wsgi module in + Designate, ``designate.wsgi.api:application`` if their chosen WSGI server + supports this (gunicorn, uWSGI, etc.) or implement a .wsgi script + themselves if not (mod_wsgi). diff --git a/setup.cfg b/setup.cfg index 56c8a35f6..2c379f954 100644 --- a/setup.cfg +++ b/setup.cfg @@ -119,6 +119,3 @@ designate.heartbeat_emitter = designate.notification.plugin = default = designate.notifications:Default audit = designate.notifications:Audit - -wsgi_scripts = - designate-api-wsgi = designate.api.wsgi:init_application