api: Dump config options when deployed as a wsgi app

This ensures api service dumps config options to debug logs when being
deployed as a wsgi app, so that users can review the effective values
and find misconfiguration more easily.

Closes-Bug: #2031480
Change-Id: I622fbae7fb273e7405a305cc3e33ac89c0564fdc
This commit is contained in:
Takashi Kajinami 2023-08-16 14:38:59 +09:00 committed by Takashi Kajinami
parent 5d48410d0a
commit 2aa2ed5119
3 changed files with 15 additions and 7 deletions

View File

@ -22,10 +22,10 @@ from manila.wsgi import wsgi
class WSGITestCase(test.TestCase):
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.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.wsgi, 'Loader')
wsgi.sys.argv = ['--verbose', '--debug']
@ -34,11 +34,11 @@ class WSGITestCase(test.TestCase):
self.assertEqual(
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(
mock.ANY, project="manila", version=wsgi.version.version_string())
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.wsgi.Loader.assert_called_once_with(mock.ANY)
wsgi.wsgi.Loader.return_value.load_app.assert_called_once_with(

View File

@ -16,7 +16,7 @@
import sys
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 opts as gmr_opts
from oslo_service import wsgi
@ -28,17 +28,20 @@ from manila import service
from manila import version
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
def initialize_application():
log.register_options(CONF)
logging.register_options(CONF)
gmr_opts.set_defaults(CONF)
CONF(sys.argv[1:], project="manila", version=version.version_string())
config.verify_share_protocols()
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)
rpc.init(CONF)
service.setup_profiler("manila-api", CONF.host)
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.