summaryrefslogtreecommitdiff
path: root/keystone
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2012-03-05 16:47:58 -0600
committerDolph Mathews <dolph.mathews@gmail.com>2012-03-06 11:06:04 -0600
commitfd4e9616ddca4dbd0c4f0545c376167b966eae8d (patch)
tree04bead4be42f5f414173f0bb3814d095a1908161 /keystone
parenta18b3f29c4a977977e6bf29d1edcba43d5e6005b (diff)
downloadkeystone-fd4e9616ddca4dbd0c4f0545c376167b966eae8d.tar.gz
Isolating backtraces to DEBUG (bug 947060)
Debug mode on: http://pastie.org/3529520 (full backtrace to stdout) Debug mode off: http://pastie.org/3529526 (Just an error message to stdout) Change-Id: I1d4e17cf73e7777c3cbaef7c5d7fd18a4f6e53dc
Diffstat (limited to 'keystone')
-rw-r--r--keystone/catalog/backends/templated.py8
-rw-r--r--keystone/common/logging.py18
-rw-r--r--keystone/service.py4
3 files changed, 29 insertions, 1 deletions
diff --git a/keystone/catalog/backends/templated.py b/keystone/catalog/backends/templated.py
index de6cf4c6e..e66e949f3 100644
--- a/keystone/catalog/backends/templated.py
+++ b/keystone/catalog/backends/templated.py
@@ -19,6 +19,8 @@ from keystone.common import logging
from keystone.catalog.backends import kvs
+LOG = logging.getLogger('keystone.catalog.backends.templated')
+
CONF = config.CONF
config.register_str('template_file', group='catalog')
@@ -90,7 +92,11 @@ class TemplatedCatalog(kvs.Catalog):
super(TemplatedCatalog, self).__init__()
def _load_templates(self, template_file):
- self.templates = parse_templates(open(template_file))
+ try:
+ self.templates = parse_templates(open(template_file))
+ except IOError:
+ LOG.critical('Unable to open template file %s' % template_file)
+ raise
def get_catalog(self, user_id, tenant_id, metadata=None):
d = dict(CONF.iteritems())
diff --git a/keystone/common/logging.py b/keystone/common/logging.py
index 0d3f46932..77d6a8e1c 100644
--- a/keystone/common/logging.py
+++ b/keystone/common/logging.py
@@ -8,6 +8,7 @@ import functools
import logging
import logging.config
import pprint
+import traceback
from logging.handlers import SysLogHandler
from logging.handlers import WatchedFileHandler
@@ -55,3 +56,20 @@ def log_debug(f):
logging.debug('')
return rv
return wrapper
+
+
+def fail_gracefully(f):
+ """Logs exceptions and aborts."""
+ @functools.wraps(f)
+ def wrapper(*args, **kw):
+ try:
+ return f(*args, **kw)
+ except Exception as e:
+ # tracebacks are kept in the debug log
+ logging.debug(traceback.format_exc(e))
+
+ # exception message is printed to all logs
+ logging.critical(e)
+
+ exit(1)
+ return wrapper
diff --git a/keystone/service.py b/keystone/service.py
index d0d447057..fdc16433a 100644
--- a/keystone/service.py
+++ b/keystone/service.py
@@ -535,24 +535,28 @@ class AdminExtensionsController(ExtensionsController):
}
+@logging.fail_gracefully
def public_app_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)
return PublicRouter()
+@logging.fail_gracefully
def admin_app_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)
return AdminRouter()
+@logging.fail_gracefully
def public_version_app_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)
return PublicVersionRouter()
+@logging.fail_gracefully
def admin_version_app_factory(global_conf, **local_conf):
conf = global_conf.copy()
conf.update(local_conf)