Optimize the way to serach file 'glance-api-paste.ini'
With the original method _get_deployment_config_file() in config.py, if the option config_file is specified in glance-api.conf, and run command 'glance-api' under a directory, the the method load_paste_app() will throw an IOError, but the IOError dose not been catched. The same error will happen with'glance-registery'. The reason for this IOError is the code "os.path.abspath(path)" in _get_deployment_config_file() will return a value '{cur_dir}/glance-api-paste.ini', but the 'glance-api-paste.ini' does not exist under {cur_dir}.Such as running the command under /opt, but the 'glance-api-paste.ini' dose not exist under /opt. This pacth modifies one line of code in method _get_paste_config_path() for solving the IOError. At the same time, it provides one test case. Change-Id: I970c1acb073700b15e153dd08c9ec14d20f0e83d Closes-Bug: 1712226
This commit is contained in:
parent
8c1c577835
commit
471fd8dd85
@ -766,7 +766,7 @@ def _get_deployment_config_file():
|
||||
path = CONF.paste_deploy.config_file
|
||||
if not path:
|
||||
path = _get_paste_config_path()
|
||||
if not path:
|
||||
if not path or not (os.path.isfile(os.path.abspath(path))):
|
||||
msg = _("Unable to locate paste config file for %s.") % CONF.prog
|
||||
raise RuntimeError(msg)
|
||||
return os.path.abspath(path)
|
||||
|
@ -95,6 +95,13 @@ class TestPasteApp(test_utils.BaseTestCase):
|
||||
self._do_test_load_paste_app(expected_middleware,
|
||||
paste_config_file=paste_config_file)
|
||||
|
||||
def test_load_paste_app_with_paste_config_file_but_not_exist(self):
|
||||
paste_config_file = os.path.abspath("glance-registry-paste.ini")
|
||||
expected_middleware = oslo_middleware.Healthcheck
|
||||
self.assertRaises(RuntimeError, self._do_test_load_paste_app,
|
||||
expected_middleware,
|
||||
paste_config_file=paste_config_file)
|
||||
|
||||
def test_get_path_non_exist(self):
|
||||
self.assertRaises(RuntimeError, config._get_deployment_config_file)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user