diff --git a/glance/common/config.py b/glance/common/config.py index 487b78b265..e61d777930 100644 --- a/glance/common/config.py +++ b/glance/common/config.py @@ -782,7 +782,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) diff --git a/glance/tests/unit/common/test_config.py b/glance/tests/unit/common/test_config.py index 0888b0507f..d91c55f0a7 100644 --- a/glance/tests/unit/common/test_config.py +++ b/glance/tests/unit/common/test_config.py @@ -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)