Reviewed: https://review.openstack.org/496069 Committed: https://git.openstack.org/cgit/openstack/glance/commit/?id=471fd8dd85b7db8799bb7913ac087bb1d554d66b Submitter: Zuul Branch: master
commit 471fd8dd85b7db8799bb7913ac087bb1d554d66b Author: zhiguo.li <[email protected]> Date: Tue Aug 22 10:07:05 2017 +0800 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 ** Changed in: glance Status: In Progress => Fix Released -- You received this bug notification because you are a member of Yahoo! Engineering Team, which is subscribed to Glance. https://bugs.launchpad.net/bugs/1712226 Title: can not find glance-api-paste.ini in a case Status in Glance: Fix Released Bug description: Test case step: 1. Enable the option "config_file" in section "paste_deploy" from configuration file glance-api.conf 2. Start the glance-api with command "glance-api --config-dir /etc/glance --log-dir /var/log/glance" in console Result: If the current directory is not in the /etc/glance, the configuration file 'glance-api-paste.ini' file will not be found. and the IOError is not been catched. The same error result will happen with glance-registery command in above case. I run the command in directory /var/log/glance/, and the error info in log shows as: 2017-08-22 09:13:49.727 22012 DEBUG glance.common.config [-] Loading glance-api-keystone from /var/log/glance/glance-api-paste.ini load_paste_app /usr/local/lib/python2.7/dist-packages/glance/common/config.py:806 2017-08-22 09:13:49.728 22012 CRITICAL glance [-] Unhandled error: IOError: [Errno 2] No such file or directory: '/var/log/glance/glance-api-paste.ini' 2017-08-22 09:13:49.728 22012 ERROR glance Traceback (most recent call last): 2017-08-22 09:13:49.728 22012 ERROR glance File "/usr/local/bin/glance-api", line 10, in <module> 2017-08-22 09:13:49.728 22012 ERROR glance sys.exit(main()) 2017-08-22 09:13:49.728 22012 ERROR glance File "/usr/local/lib/python2.7/dist-packages/glance/cmd/api.py", line 88, in main 2017-08-22 09:13:49.728 22012 ERROR glance server.start(config.load_paste_app('glance-api'), default_port=9292) 2017-08-22 09:13:49.728 22012 ERROR glance File "/usr/local/lib/python2.7/dist-packages/glance/common/config.py", line 808, in load_paste_app 2017-08-22 09:13:49.728 22012 ERROR glance app = deploy.loadapp("config:%s" % conf_file, name=app_name) 2017-08-22 09:13:49.728 22012 ERROR glance File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 247, in loadapp 2017-08-22 09:13:49.728 22012 ERROR glance return loadobj(APP, uri, name=name, **kw) 2017-08-22 09:13:49.728 22012 ERROR glance File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 271, in loadobj 2017-08-22 09:13:49.728 22012 ERROR glance global_conf=global_conf) 2017-08-22 09:13:49.728 22012 ERROR glance File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext 2017-08-22 09:13:49.728 22012 ERROR glance global_conf=global_conf) 2017-08-22 09:13:49.728 22012 ERROR glance File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 317, in _loadconfig 2017-08-22 09:13:49.728 22012 ERROR glance loader = ConfigLoader(path) 2017-08-22 09:13:49.728 22012 ERROR glance File "/usr/local/lib/python2.7/dist-packages/paste/deploy/loadwsgi.py", line 393, in __init__ 2017-08-22 09:13:49.728 22012 ERROR glance with open(filename) as f: 2017-08-22 09:13:49.728 22012 ERROR glance IOError: [Errno 2] No such file or directory: '/var/log/glance/glance-api-paste.ini' 2017-08-22 09:13:49.728 22012 ERROR glance To manage notifications about this bug go to: https://bugs.launchpad.net/glance/+bug/1712226/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

