Skip to content

Commit

Permalink
Allow pecan debug middleware to be turned off
Browse files Browse the repository at this point in the history
The Pecan DebugMiddleware is turned on or off based on the
ceilometer.conf-wide debug setting. This is not useful for situations
where running ceilometer-api under mod_wsgi with multiple processes
is desired.

This change adds a pecan_debug setting to the api section of config,
defaulting to the DEFAULT debug value. mod_wsgi install docs updated
accordingly.

Configuration docs have not yet been udpated. They will be pending a
fix to bug 1370030

Closes-Bug: #1370009

Change-Id: Ib4a472e3c8d1f34f64a5f3ab993c1211dee8af9a
  • Loading branch information
Chris Dent committed Sep 17, 2014
1 parent 85b859f commit 8691ba8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 11 additions & 2 deletions ceilometer/api/app.py
Expand Up @@ -40,8 +40,17 @@
),
]

api_opts = [
cfg.BoolOpt('pecan_debug',
default='$debug',
help='Toggle Pecan Debug Middleware. '
'Defaults to global debug value.'
),
]

CONF = cfg.CONF
CONF.register_opts(auth_opts)
CONF.register_opts(api_opts, group='api')


def get_pecan_config():
Expand Down Expand Up @@ -70,7 +79,7 @@ def setup_app(pecan_config=None, extra_hooks=None):
pecan_config.app.root,
static_root=pecan_config.app.static_root,
template_path=pecan_config.app.template_path,
debug=CONF.debug,
debug=CONF.api.pecan_debug,
force_canonical=getattr(pecan_config.app, 'force_canonical', True),
hooks=app_hooks,
wrap_app=middleware.ParsableErrorMiddleware,
Expand All @@ -83,7 +92,7 @@ def setup_app(pecan_config=None, extra_hooks=None):
class VersionSelectorApplication(object):
def __init__(self):
pc = get_pecan_config()
pc.app.debug = CONF.debug
pc.app.debug = CONF.api.pecan_debug

def not_found(environ, start_response):
start_response('404 Not Found', [])
Expand Down
10 changes: 3 additions & 7 deletions doc/source/install/mod_wsgi.rst
Expand Up @@ -60,10 +60,6 @@ Limitation

As Ceilometer is using Pecan and Pecan's DebugMiddleware doesn't support
multiple processes, there is no way to set debug mode in the multiprocessing
case. So user will run into HTTP 500 error if the mod_wsgi's multiprocessing
is enabled and the Ceilometer debug mode is enabled at the same time. There
is no good way to make both of them work, since Pecan is sharing the debug
mode with Ceilometer, see[1]. If you really need to enable both, a possible
workaround is hacking that line and hardcode the debug configration to False.

[1] https://github.com/openstack/ceilometer/blob/master/ceilometer/api/app.py
case. To allow multiple processes the DebugMiddleware may be turned off by
setting ``pecan_debug`` to ``False`` in the ``api`` section of
``ceilometer.conf``.

0 comments on commit 8691ba8

Please sign in to comment.