Merge "Use consistent program name for wsgi scripts and entry points"

This commit is contained in:
Zuul
2025-12-08 22:18:34 +00:00
committed by Gerrit Code Review
7 changed files with 32 additions and 12 deletions
+7 -4
View File
@@ -98,14 +98,17 @@ def error_application(exc, name):
@utils.run_once('Global data already initialized, not re-initializing.',
LOG.info)
def init_global_data(conf_files, service_name):
def init_global_data(conf_files, service_name, prog):
# NOTE(melwitt): parse_args initializes logging and calls global rpc.init()
# and db_api.configure(). The db_api.configure() call does not initiate any
# connection to the database.
# NOTE(gibi): sys.argv is set by the wsgi runner e.g. uwsgi sets it based
# on the --pyargv parameter of the uwsgi binary
config.parse_args(sys.argv, default_config_files=conf_files)
config.parse_args(
sys.argv,
default_config_files=conf_files,
prog=prog)
logging.setup(CONF, "nova")
gmr_opts.set_defaults(CONF)
@@ -119,7 +122,7 @@ def init_global_data(conf_files, service_name):
@utils.latch_error_on_raise(retryable=(odbe.DBConnectionError,))
def init_application(name):
def init_application(name, prog):
conf_files = _get_config_files()
# NOTE(melwitt): The init_application method can be called multiple times
@@ -128,7 +131,7 @@ def init_application(name):
# apache/mod_wsgi reloads the init_application script. So, we initialize
# global data separately and decorate the method to run only once in a
# python interpreter instance.
init_global_data(conf_files, name)
init_global_data(conf_files, name, prog)
try:
_setup_service(CONF.host, name)
+2 -1
View File
@@ -79,7 +79,7 @@ def set_log_defaults():
def parse_args(argv, default_config_files=None, configure_db=True,
init_rpc=True):
init_rpc=True, prog=None):
log.register_options(CONF)
# NOTE(sean-k-mooney): this filter addresses bug #1825584
@@ -94,6 +94,7 @@ def parse_args(argv, default_config_files=None, configure_db=True,
CONF(argv[1:],
project='nova',
prog=prog,
version=version.version_string(),
default_config_files=default_config_files)
@@ -82,13 +82,13 @@ document_root = /tmp
# Run init_application the first time, simulating an exception being
# raised during it.
self.assertRaises(test.TestingException, wsgi_app.init_application,
'nova-api')
'nova-api', 'nova-api')
# reset the latch_error_on_raise decorator
wsgi_app.init_application.reset()
# Now run init_application a second time, it should succeed since no
# exception is being raised (the init of global data should not be
# re-attempted).
wsgi_app.init_application('nova-api')
wsgi_app.init_application('nova-api', 'nova-api')
self.assertIn('Global data already initialized, not re-initializing.',
self.stdlog.logger.output)
@@ -106,7 +106,8 @@ document_root = /tmp
error, test.TestingException, test.TestingException]
for i in range(3):
e = self.assertRaises(
excepted_type, wsgi_app.init_application, 'nova-api')
excepted_type, wsgi_app.init_application, 'nova-api',
'nova-api')
self.assertIs(e, error)
# since the expction is latched on the first raise mock_get_files
# should not be called again on each iteration
+3 -2
View File
@@ -31,8 +31,9 @@ class TestInitApplication(test.NoDBTestCase):
with utils.temporary_mutation(sys, argv=mock.sentinel.argv):
with mock.patch('nova.config.parse_args') as mock_parse_args:
wsgi_app.init_application('test-app')
wsgi_app.init_application('test-app', 'test-app')
mock_parse_args.assert_called_once_with(
mock.sentinel.argv,
default_config_files=[
'/etc/nova/api-paste.ini', '/etc/nova/nova.conf'])
'/etc/nova/api-paste.ini', '/etc/nova/nova.conf'],
prog='test-app')
+2 -1
View File
@@ -20,9 +20,10 @@ import threading
from nova.api.openstack import wsgi_app
NAME = "metadata"
PROG = "nova-api-metadata"
application = None
lock = threading.Lock()
with lock:
if application is None:
application = wsgi_app.init_application(NAME)
application = wsgi_app.init_application(NAME, PROG)
+2 -1
View File
@@ -20,9 +20,10 @@ import threading
from nova.api.openstack import wsgi_app
NAME = "osapi_compute"
PROG = "nova-api-os-compute"
application = None
lock = threading.Lock()
with lock:
if application is None:
application = wsgi_app.init_application(NAME)
application = wsgi_app.init_application(NAME, PROG)
@@ -0,0 +1,12 @@
---
fixes:
- |
[`bug 2098514 <https://bugs.launchpad.net/nova/+bug/2098514>_`] Fixed
the per-service configuration directories for the API wsgi modules
(``nova.wsgi.osapi_compute`` and ``nova.wsgi.metadata``), unexpectedly
affected by the application servers hosting these. Now these modules use
the following per-service configuration directories regardless of
the application server used.
- ``nova.wsgi.osapi_compute``: ``/etc/nova/nova-api-os-compute.d``
- ``nova.wsgi.metadata``: ``/etc/nova/nova-api-metadata.d``