summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Mooney <work@seanmooney.info>2022-11-08 15:00:22 +0000
committerBalazs Gibizer <gibizer@gmail.com>2022-12-12 15:35:49 +0000
commitd92d0934188a14741dd86949ddf98bd1208f3d96 (patch)
tree0e4c8ee5905cb000e96166fa40588305823d37ed
parent0ebcc5f9059d29ab2d595562f98aec89bf03073a (diff)
downloadnova-d92d0934188a14741dd86949ddf98bd1208f3d96.tar.gz
Support multiple config file with mod_wsgi
Unlike uwsgi, apache mod_wsgi does not support passing commandline arguments to the python wsgi script it invokes. As a result while you can pass --config-file when hosting the api and metadata wsgi applications with uwsgi there is no way to use multiple config files with mod_wsgi. This change mirrors how this is supported in keystone today by intoducing a new OS_NOVA_CONFIG_FILES env var to allow operators to optional pass a ';' delimited list of config files to load. This change also add docs for this env var and the existing undocumented OS_NOVA_CONFIG_DIR. Closes-Bug: 1994056 Change-Id: I8e3ccd75cbb7f2e132b403cb38022787c2c0a37b (cherry picked from commit 73fe84fa0ea6f7c7fa55544f6bce5326d87743a6)
-rw-r--r--doc/source/user/wsgi.rst14
-rw-r--r--nova/api/openstack/wsgi_app.py5
-rw-r--r--nova/tests/unit/api/openstack/test_wsgi_app.py15
-rw-r--r--releasenotes/notes/multiple-config-files-with-mod_wsgi-f114ea5fdd8b9a51.yaml14
4 files changed, 43 insertions, 5 deletions
diff --git a/doc/source/user/wsgi.rst b/doc/source/user/wsgi.rst
index 6b314b4832..63f949df1a 100644
--- a/doc/source/user/wsgi.rst
+++ b/doc/source/user/wsgi.rst
@@ -8,10 +8,16 @@ as Apache_ or nginx_).
The nova project provides two automatically generated entry points that
support this: ``nova-api-wsgi`` and ``nova-metadata-wsgi``. These read
-``nova.conf`` and ``api-paste.ini`` and generate the required module-level
-``application`` that most WSGI servers require. If nova is installed using pip,
-these two scripts will be installed into whatever the expected ``bin``
-directory is for the environment.
+``nova.conf`` and ``api-paste.ini`` by default and generate the required
+module-level ``application`` that most WSGI servers require.
+If nova is installed using pip, these two scripts will be installed into
+whatever the expected ``bin`` directory is for the environment.
+
+The config files and config directory can be overridden via the
+``OS_NOVA_CONFIG_FILES`` and ``OS_NOVA_CONFIG_DIR`` environment variables.
+File paths listed in ``OS_NOVA_CONFIG_FILES`` are relative to
+``OS_NOVA_CONFIG_DIR`` and delimited by ``;``.
+
The new scripts replace older experimental scripts that could be found in the
``nova/wsgi`` directory of the code repository. The new scripts are *not*
diff --git a/nova/api/openstack/wsgi_app.py b/nova/api/openstack/wsgi_app.py
index d60069ce84..6a2b72a611 100644
--- a/nova/api/openstack/wsgi_app.py
+++ b/nova/api/openstack/wsgi_app.py
@@ -42,8 +42,11 @@ def _get_config_files(env=None):
if env is None:
env = os.environ
dirname = env.get('OS_NOVA_CONFIG_DIR', '/etc/nova').strip()
+ files = env.get('OS_NOVA_CONFIG_FILES', '').split(';')
+ if files == ['']:
+ files = CONFIG_FILES
return [os.path.join(dirname, config_file)
- for config_file in CONFIG_FILES]
+ for config_file in files]
def _setup_service(host, name):
diff --git a/nova/tests/unit/api/openstack/test_wsgi_app.py b/nova/tests/unit/api/openstack/test_wsgi_app.py
index 94e2fe5cb1..0eb7011c11 100644
--- a/nova/tests/unit/api/openstack/test_wsgi_app.py
+++ b/nova/tests/unit/api/openstack/test_wsgi_app.py
@@ -104,3 +104,18 @@ document_root = /tmp
'disable_compute_service_check_for_ffu', True,
group='workarounds')
wsgi_app._setup_service('myhost', 'api')
+
+ def test__get_config_files_empty_env(self):
+ env = {}
+ result = wsgi_app._get_config_files(env)
+ expected = ['/etc/nova/api-paste.ini', '/etc/nova/nova.conf']
+ self.assertEqual(result, expected)
+
+ def test__get_config_files_with_env(self):
+ env = {
+ "OS_NOVA_CONFIG_DIR": "/nova",
+ "OS_NOVA_CONFIG_FILES": "api.conf",
+ }
+ result = wsgi_app._get_config_files(env)
+ expected = ['/nova/api.conf']
+ self.assertEqual(result, expected)
diff --git a/releasenotes/notes/multiple-config-files-with-mod_wsgi-f114ea5fdd8b9a51.yaml b/releasenotes/notes/multiple-config-files-with-mod_wsgi-f114ea5fdd8b9a51.yaml
new file mode 100644
index 0000000000..f4361477de
--- /dev/null
+++ b/releasenotes/notes/multiple-config-files-with-mod_wsgi-f114ea5fdd8b9a51.yaml
@@ -0,0 +1,14 @@
+---
+fixes:
+ - |
+ apache mod_wsgi does not support passing commandline arguments to the wsgi
+ application that it hosts. As a result when the nova api or metadata api
+ where run under mod_wsgi it was not posible to use multiple config files
+ or non-default file names i.e. nova-api.conf
+ This has been adressed by the intoduction of a new, optional, envionment
+ varible ``OS_NOVA_CONFIG_FILES``. ``OS_NOVA_CONFIG_FILES`` is a ``;``
+ seperated list fo file path relitive to ``OS_NOVA_CONFIG_DIR``.
+ When unset the default ``api-paste.ini`` and ``nova.conf`` will be used
+ form ``/etc/nova``. This is supported for the nova api and nova metadata
+ wsgi applications.
+