keystone's use of logging.isEnabledFor breaks python 2.6 compatibility

Bug #1213284 reported by Jay Buffington
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
High
Lance Bragstad

Bug Description

commit 0c2fc69b started using the isEnabledFor() method on logging which wasn't introduced until python 2.7

From http://docs.python.org/2/library/logging.html#loggeradapter-objects
"Changed in version 2.7: The isEnabledFor() method was added to LoggerAdapter. This method delegates to the underlying logger."

This means that if you try to run keystone under python 2.6 you get this error:

    2013-08-16 22:55:52,608 (keystone.common.wsgi): ERROR wsgi __call__ ContextAdapter instance has no attribute 'isEnabledFor'

Revision history for this message
Dolph Mathews (dolph) wrote :

This may be resolved in havana as a side effect of:

  https://blueprints.launchpad.net/keystone/+spec/unified-logging-in-keystone

Are you seeing this in folsom, grizzly or master?

Revision history for this message
Jay Buffington (jaybuff) wrote :

I'm seeing this in master. This bug is actually a *result* of the unified logging in keystone print, which commit 0c2fc69b implements. keystone worked under py26 prior to that commit.

To replicate:

    $ git checkout 0c2fc69b~1
    HEAD is now at 14e0901... Move 'tests' directory into 'keystone' package

    $ python2.6
    Python 2.6.6 (r266:84292, Sep 11 2012, 05:13:24)
    [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from keystone.common import logging
    >>> LOG = logging.getLogger(__name__)
    >>> LOG.isEnabledFor(logging.DEBUG)
    False
    >>>

    $ git checkout 0c2fc69b
    Previous HEAD position was 14e0901... Move 'tests' directory into 'keystone' package
    HEAD is now at 0c2fc69... Refactor Keystone to use unified logging from Oslo

    $ python2.6
    Python 2.6.6 (r266:84292, Sep 11 2012, 05:13:24)
    [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from keystone.openstack.common import log as logging
    >>> LOG = logging.getLogger(__name__)
    >>> LOG.isEnabledFor(LOG.debug)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: ContextAdapter instance has no attribute 'isEnabledFor'
    >>>

I am using the LDAP backend, which uses isEnabledFor:

    $ grep -rI isEnabledFor keystone/*
    keystone/common/ldap/core.py: if LOG.isEnabledFor(LOG.debug):
    keystone/common/ldap/core.py: if LOG.isEnabledFor(LOG.debug):
    keystone/common/ldap/core.py: if LOG.isEnabledFor(LOG.debug):
    keystone/common/wsgi.py: if LOG.isEnabledFor(LOG.debug):
    keystone/common/wsgi.py: if LOG.isEnabledFor(LOG.debug):
    $

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

Fix proposed to branch: master
Review: https://review.openstack.org/42674

Changed in keystone:
assignee: nobody → Lance Bragstad (ldbragst)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/42674
Committed: http://github.com/openstack/keystone/commit/cfebb34f7c57284e752e74a24266ad5f463789ef
Submitter: Jenkins
Branch: master

commit cfebb34f7c57284e752e74a24266ad5f463789ef
Author: Lance Bragstad <email address hidden>
Date: Mon Aug 19 16:12:11 2013 +0000

    Fix isEnabledFor for compatibility with logging

    After refactoring Keystone to use the unified logging implementation
    from Oslo-incubator there were some issues using isEnabledFor with the
    ContextAdapter provided in keystone/openstack/common/log.py. This
    removes those calls and adds a check in keystone/common/wsgi.py to
    handle the case where Keystone is running Python 2.6, in which
    ContextAdapter doesn't have 'isEnabledFor'.

    fixes bug 1213284

    Change-Id: I8c64b12dcd9d955c96dc5a48348555ff37b15116

Changed in keystone:
status: In Progress → Fix Committed
Dolph Mathews (dolph)
Changed in keystone:
importance: Undecided → High
Thierry Carrez (ttx)
Changed in keystone:
milestone: none → havana-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: havana-3 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.