From 2079810c1275997b71ec237979a4dc3df32a0e35 Mon Sep 17 00:00:00 2001 From: Simon Zhou Date: Sun, 3 May 2026 08:06:00 +0000 Subject: [PATCH] api: pass args=[] to oslo.config in init_application 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 --- heat/api/cfn/wsgi.py | 3 ++- heat/api/openstack/wsgi.py | 2 +- .../fix-wsgi-init-args-empty-9d86398edce73f54.yaml | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-wsgi-init-args-empty-9d86398edce73f54.yaml diff --git a/heat/api/cfn/wsgi.py b/heat/api/cfn/wsgi.py index 108e95ec66..a7d1f99f3a 100644 --- a/heat/api/cfn/wsgi.py +++ b/heat/api/cfn/wsgi.py @@ -37,7 +37,8 @@ def init_application(): # already contain registered options if the app is reloaded. CONF.reset() logging.register_options(CONF) - CONF(project='heat', + CONF(args=[], + project='heat', prog='heat-api-cfn', version=version.version_info.version_string()) logging.setup(CONF, CONF.prog) diff --git a/heat/api/openstack/wsgi.py b/heat/api/openstack/wsgi.py index ef2cfb64af..db247ddebb 100644 --- a/heat/api/openstack/wsgi.py +++ b/heat/api/openstack/wsgi.py @@ -38,7 +38,7 @@ def init_application(): CONF.reset() logging.register_options(CONF) version = hversion.version_info.version_string() - CONF(project='heat', prog='heat-api', version=version) + CONF(args=[], project='heat', prog='heat-api', version=version) logging.setup(CONF, CONF.prog) config.set_config_defaults() messaging.setup() diff --git a/releasenotes/notes/fix-wsgi-init-args-empty-9d86398edce73f54.yaml b/releasenotes/notes/fix-wsgi-init-args-empty-9d86398edce73f54.yaml new file mode 100644 index 0000000000..4b99103dab --- /dev/null +++ b/releasenotes/notes/fix-wsgi-init-args-empty-9d86398edce73f54.yaml @@ -0,0 +1,11 @@ +--- +fixes: + - | + Fixed an issue where ``heat-api`` and ``heat-api-cfn``, when running + under uWSGI with ``wsgi-file``, could fail to load the WSGI application + with ``unable to load app 0 ... (callable not found or import error)``. + The ``init_application`` functions in ``heat.api.openstack.wsgi`` and + ``heat.api.cfn.wsgi`` invoked ``oslo.config`` without ``args=[]``, so + ``oslo.config`` fell back to ``sys.argv[1:]`` and rejected uWSGI's own + arguments (e.g. ``--ini``) with ``SystemExit(2)``. The calls now pass + an explicit empty argument list.