api: pass args=[] to oslo.config in init_application#18
Open
fivetime wants to merge 1 commit intoopenstack:masterfrom
Open
api: pass args=[] to oslo.config in init_application#18fivetime wants to merge 1 commit intoopenstack:masterfrom
fivetime wants to merge 1 commit intoopenstack:masterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix heat-api / heat-api-cfn failing to load WSGI app under uWSGI with
wsgi-file.init_application()callsoslo.configwithoutargs, so it falls back tosys.argv[1:]and chokes on uWSGI's own--iniargument withSystemExit(2). Passargs=[]explicitly.Affects both
heat/api/cfn/wsgi.pyandheat/api/openstack/wsgi.py.Reproduction
In a uWSGI deployment using:
The pod stays Running but every HTTP request returns 500 with:
Verified
End-to-end reproduced and fix-verified inside a real
quay.io/airshipit/heat:2025.2-ubuntu_noblecontainer: with the patchedinit_application, the WSGI callable loads (<class 'oslo_middleware.cors.CORS'>); without the patch it raisesSystemExit(2).Test plan
init_application()withsys.argv = ["uwsgi", "--ini", ...]— no longer SystemExit.🤖 Generated with Claude Code