Skip to content

api: pass args=[] to oslo.config in init_application#18

Open
fivetime wants to merge 1 commit intoopenstack:masterfrom
fivetime:fix-wsgi-args-empty
Open

api: pass args=[] to oslo.config in init_application#18
fivetime wants to merge 1 commit intoopenstack:masterfrom
fivetime:fix-wsgi-args-empty

Conversation

@fivetime
Copy link
Copy Markdown

@fivetime fivetime commented May 3, 2026

Summary

Fix heat-api / heat-api-cfn failing to load WSGI app under uWSGI with wsgi-file. init_application() calls oslo.config without args, so it falls back to sys.argv[1:] and chokes on uWSGI's own --ini argument with SystemExit(2). Pass args=[] explicitly.

Affects both heat/api/cfn/wsgi.py and heat/api/openstack/wsgi.py.

Reproduction

In a uWSGI deployment using:

[uwsgi]
http-socket = 0.0.0.0:8000
wsgi-file = /var/lib/openstack/bin/heat-wsgi-api-cfn

The pod stays Running but every HTTP request returns 500 with:

unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***

Verified

End-to-end reproduced and fix-verified inside a real quay.io/airshipit/heat:2025.2-ubuntu_noble container: with the patched init_application, the WSGI callable loads (<class 'oslo_middleware.cors.CORS'>); without the patch it raises SystemExit(2).

Test plan

  • Run init_application() with sys.argv = ["uwsgi", "--ini", ...] — no longer SystemExit.
  • CI: pep8, py3, functional.

🤖 Generated with Claude Code

When heat-api or heat-api-cfn is started under uWSGI with
``wsgi-file = /var/lib/openstack/bin/heat-wsgi-api[-cfn]``, the WSGI
application fails to load:

    unable to load app 0 (mountpoint='') (callable not found or import error)
    *** no app loaded. going in full dynamic mode ***

The root cause is that ``init_application`` in ``heat.api.cfn.wsgi`` and
``heat.api.openstack.wsgi`` invokes ``oslo.config`` without the ``args``
keyword argument. ``ConfigOpts.__call__`` defaults to ``args=None``,
which falls back to ``sys.argv[1:]``. Under uWSGI, ``sys.argv`` is
``["uwsgi", "--ini", "/etc/heat/heat-api-...-uwsgi.ini", ...]``. The
unrecognized ``--ini`` argument causes ``oslo.config`` to call
``sys.exit(2)``, so the WSGI callable is never bound and every request
returns HTTP 500. The pod can stay in ``Running`` (uWSGI master/worker
keep going) but readiness probes fail forever.

Pass an explicit empty argument list so ``oslo.config`` ignores
``sys.argv`` entirely. The configuration is already loaded from
``/etc/heat/heat.conf`` via paste, which is unaffected.

Change-Id: I9d86398edce73f54a5e3b99aae12848c597ff502
Signed-off-by: Simon Zhou <jp.zdm2008@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant