Merge "api: Dump config options when deployed as a wsgi app"

This commit is contained in:
Zuul 2024-02-05 17:20:02 +00:00 committed by Gerrit Code Review
commit a83a4b1165
3 changed files with 15 additions and 7 deletions

View File

@ -22,10 +22,10 @@ from manila.wsgi import wsgi
class WSGITestCase(test.TestCase): class WSGITestCase(test.TestCase):
def test_initialize_application(self): def test_initialize_application(self):
self.mock_object(wsgi.log, 'register_options') self.mock_object(wsgi.logging, 'register_options')
self.mock_object(wsgi.cfg.ConfigOpts, '__call__') self.mock_object(wsgi.cfg.ConfigOpts, '__call__')
self.mock_object(wsgi.config, 'verify_share_protocols') self.mock_object(wsgi.config, 'verify_share_protocols')
self.mock_object(wsgi.log, 'setup') self.mock_object(wsgi.logging, 'setup')
self.mock_object(wsgi.rpc, 'init') self.mock_object(wsgi.rpc, 'init')
self.mock_object(wsgi.wsgi, 'Loader') self.mock_object(wsgi.wsgi, 'Loader')
wsgi.sys.argv = ['--verbose', '--debug'] wsgi.sys.argv = ['--verbose', '--debug']
@ -34,11 +34,11 @@ class WSGITestCase(test.TestCase):
self.assertEqual( self.assertEqual(
wsgi.wsgi.Loader.return_value.load_app.return_value, result) wsgi.wsgi.Loader.return_value.load_app.return_value, result)
wsgi.log.register_options.assert_called_once_with(mock.ANY) wsgi.logging.register_options.assert_called_once_with(mock.ANY)
wsgi.cfg.ConfigOpts.__call__.assert_called_once_with( wsgi.cfg.ConfigOpts.__call__.assert_called_once_with(
mock.ANY, project="manila", version=wsgi.version.version_string()) mock.ANY, project="manila", version=wsgi.version.version_string())
wsgi.config.verify_share_protocols.assert_called_once_with() wsgi.config.verify_share_protocols.assert_called_once_with()
wsgi.log.setup.assert_called_once_with(mock.ANY, "manila") wsgi.logging.setup.assert_called_once_with(mock.ANY, "manila")
wsgi.rpc.init.assert_called_once_with(mock.ANY) wsgi.rpc.init.assert_called_once_with(mock.ANY)
wsgi.wsgi.Loader.assert_called_once_with(mock.ANY) wsgi.wsgi.Loader.assert_called_once_with(mock.ANY)
wsgi.wsgi.Loader.return_value.load_app.assert_called_once_with( wsgi.wsgi.Loader.return_value.load_app.assert_called_once_with(

View File

@ -16,7 +16,7 @@
import sys import sys
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log from oslo_log import log as logging
from oslo_reports import guru_meditation_report as gmr from oslo_reports import guru_meditation_report as gmr
from oslo_reports import opts as gmr_opts from oslo_reports import opts as gmr_opts
from oslo_service import wsgi from oslo_service import wsgi
@ -28,17 +28,20 @@ from manila import service
from manila import version from manila import version
CONF = cfg.CONF CONF = cfg.CONF
LOG = logging.getLogger(__name__)
def initialize_application(): def initialize_application():
log.register_options(CONF) logging.register_options(CONF)
gmr_opts.set_defaults(CONF) gmr_opts.set_defaults(CONF)
CONF(sys.argv[1:], project="manila", version=version.version_string()) CONF(sys.argv[1:], project="manila", version=version.version_string())
config.verify_share_protocols() config.verify_share_protocols()
config.set_lib_defaults() config.set_lib_defaults()
log.setup(CONF, "manila") logging.setup(CONF, "manila")
CONF.log_opt_values(LOG, logging.DEBUG)
gmr.TextGuruMeditation.setup_autorun(version, conf=CONF) gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)
rpc.init(CONF) rpc.init(CONF)
service.setup_profiler("manila-api", CONF.host) service.setup_profiler("manila-api", CONF.host)
return wsgi.Loader(CONF).load_app(name='osapi_share') return wsgi.Loader(CONF).load_app(name='osapi_share')

View File

@ -0,0 +1,5 @@
---
features:
- |
Now the ``manila-wsgi`` WSGI application records all options and loaded
values to its log file, when debug log is enabled.