nova-api does not support config dirs when run under apache via mod_wsgi

Bug #1994056 reported by sean mooney
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
sean mooney
placement
In Progress
Undecided
sean mooney

Bug Description

currently nova assume that when the nova-api si run under a wsgi server that server supports
passing command line arguments to the wsgi script.

that is not the case with mod_wsgi

as a result we do not support using a config director when running under mod_wsgi or passing any other arguments.

as a result when we run nova-api under mod_wsgi we fallback to a hardcoded set of config file names

https://github.com/openstack/nova/blob/b1958b7cfa6b8aca5b76b3f133627bb733d29f00/nova/api/openstack/wsgi_app.py#L34-L46

CONFIG_FILES = ['api-paste.ini', 'nova.conf']

LOG = logging.getLogger(__name__)

objects.register_all()

def _get_config_files(env=None):
    if env is None:
        env = os.environ
    dirname = env.get('OS_NOVA_CONFIG_DIR', '/etc/nova').strip()
    return [os.path.join(dirname, config_file)
            for config_file in CONFIG_FILES]

This prevents operators form using the /etc/nova/nova.config.d/
to provide a directory containing multiple config files

This can be addressed in several ways.

first we can provide a env varabel for additional command line args to be parsed
these can be parsed here as we do for uwsgi or the python wsgi server
https://github.com/openstack/nova/blob/b1958b7cfa6b8aca5b76b3f133627bb733d29f00/nova/api/openstack/wsgi_app.py#L96-L98

second we could replace or augment our custom _get_config_files with a call to the genirc implementation provide in oslo.config

https://github.com/openstack/oslo.config/blob/68cefad313bd03522e99b3de95f1786ebea45d4b/oslo_config/cfg.py#L281-L339

thrid we can provide a way to extend
CONFIG_FILES = ['api-paste.ini', 'nova.conf']
via a new env var.
e.g. OS_NOVA_EXTRA_CONFIGS="nova.config.d/01-nova.conf,nova.config.d/02-nova-secret.conf,"

we can do all three or any one of them to enable the usecase of supporting config directories although only the first option allows other command line args to be passed.

Revision history for this message
sean mooney (sean-k-mooney) wrote :

after reviewing some of the main openstack porjects (keystone, glance cinder placment)

only keystone currenlty porvides a way to configure the config files when running under mod_wsgi

there solution is to expose an envionment variabel to allow the opeartor to list the files to load.

https://github.com/openstack/keystone/blob/7d4047cb69139c22f4e321e9ba8b287a47168df2/keystone/server/flask/core.py#L74-L88

to keep concitnecy i will adopt the same appch defaulting the configs to the current set but adding a OS_NOVA_CONFIG_FILES atribute. i will also use ";" as the seperator insted of comma for consitency.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/nova/+/864014

Changed in nova:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.opendev.org/c/openstack/nova/+/864014
Committed: https://opendev.org/openstack/nova/commit/73fe84fa0ea6f7c7fa55544f6bce5326d87743a6
Submitter: "Zuul (22348)"
Branch: master

commit 73fe84fa0ea6f7c7fa55544f6bce5326d87743a6
Author: Sean Mooney <email address hidden>
Date: Tue Nov 8 15:00:22 2022 +0000

    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

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/zed)

Fix proposed to branch: stable/zed
Review: https://review.opendev.org/c/openstack/nova/+/867162

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/zed)

Reviewed: https://review.opendev.org/c/openstack/nova/+/867162
Committed: https://opendev.org/openstack/nova/commit/d92d0934188a14741dd86949ddf98bd1208f3d96
Submitter: "Zuul (22348)"
Branch: stable/zed

commit d92d0934188a14741dd86949ddf98bd1208f3d96
Author: Sean Mooney <email address hidden>
Date: Tue Nov 8 15:00:22 2022 +0000

    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)

tags: added: in-stable-zed
Changed in placement:
assignee: nobody → sean mooney (sean-k-mooney)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to placement (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/placement/+/869863

Changed in placement:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 26.1.0

This issue was fixed in the openstack/nova 26.1.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 27.0.0.0rc1

This issue was fixed in the openstack/nova 27.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on placement (master)

Change abandoned by "sean mooney <email address hidden>" on branch: master
Review: https://review.opendev.org/c/openstack/placement/+/869863
Reason: i discoverd later that htis is not needed.

while you cant pass an array of or set of config files to placement

placement will look in /etc/placement/placement.conf.d/ for all .conf files and load them using so this is not need

multiple config files can be placed in /etc/placement/placement.conf.d/ or any other direcotry search by oslo.config find_config_dirs

https://github.com/openstack/oslo.config/blob/68cefad313bd03522e99b3de95f1786ebea45d4b/oslo_config/cfg.py#L312-L339

"""
We default to two config dirs: [${project}.conf.d/, ${prog}.conf.d/].
    If no project name is supplied, we only look for ${prog.conf.d/}.

    And we look for those config dirs in the following directories::

      ~/.${project}/
      ~/
      /etc/${project}/
      /etc/
      ${SNAP_COMMON}/etc/${project}
      ${SNAP}/etc/${project}
"""

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.