openstack.common.log.setup() failures can be hard to understand

Bug #1154245 reported by James Li
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
Fix Released
Medium
Mark McLoughlin

Bug Description

Affected version: 2013.1

openstack.common.log.setup() does not check the existence of log conf file. If the specified file is not there, a 'NoSectionError' exception and a messy stack trace will be thrown (see below), which is actually not accurate. Should distinguish between non-existence and invalidation of the file.

# /usr/bin/glance-scrubber --log-config=/home/lijam/log.XX
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/glance/openstack/common/log.py", line 332, in setup
    logging.config.fileConfig(CONF.log_config)
  File "/usr/lib/python2.7/logging/config.py", line 70, in fileConfig
    formatters = _create_formatters(cp)
  File "/usr/lib/python2.7/logging/config.py", line 106, in _create_formatters
    flist = cp.get("formatters", "keys")
  File "/usr/lib/python2.7/ConfigParser.py", line 607, in get
    raise NoSectionError(section)
NoSectionError: No section: 'formatters'
No handlers could be found for logger "glance"

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

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

Changed in oslo:
assignee: nobody → James Li (james-li-3)
status: New → In Progress
Revision history for this message
Mark McLoughlin (markmc) wrote : Re: openstack.common.log.setup() does not check the existence of log conf file.

Thanks for the report and the patch

I think this is basically a duplicate of bug #1065430 - see the discussion on https://review.openstack.org/#/c/24092/

Revision history for this message
Mark McLoughlin (markmc) wrote :

Sorry, sorry - I completely misread this. Nevermind my comment

Revision history for this message
Mark McLoughlin (markmc) wrote :

Could you show us what the "messy traceback" is?

Changed in oslo:
status: In Progress → Incomplete
Revision history for this message
James Li (james-li-3) wrote :

# /usr/bin/glance-scrubber --log-config=/home/lijam/log.XX
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/glance/openstack/common/log.py", line 332, in setup
    logging.config.fileConfig(CONF.log_config)
  File "/usr/lib/python2.7/logging/config.py", line 70, in fileConfig
    formatters = _create_formatters(cp)
  File "/usr/lib/python2.7/logging/config.py", line 106, in _create_formatters
    flist = cp.get("formatters", "keys")
  File "/usr/lib/python2.7/ConfigParser.py", line 607, in get
    raise NoSectionError(section)
NoSectionError: No section: 'formatters'
No handlers could be found for logger "glance"

James Li (james-li-3)
description: updated
Changed in oslo:
status: Incomplete → In Progress
James Li (james-li-3)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo-incubator (master)

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

Changed in oslo:
assignee: James Li (james-li-3) → Mark McLoughlin (markmc)
Mark McLoughlin (markmc)
Changed in oslo:
importance: Undecided → Medium
summary: - openstack.common.log.setup() does not check the existence of log conf
- file.
+ openstack.common.log.setup() failures can be hard to understand
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo-incubator (master)

Reviewed: https://review.openstack.org/25111
Committed: http://github.com/openstack/oslo-incubator/commit/c87e615bf98981219c2f92242f6ff9ee6753d786
Submitter: Jenkins
Branch: master

commit c87e615bf98981219c2f92242f6ff9ee6753d786
Author: Mark McLoughlin <email address hidden>
Date: Fri Mar 22 07:32:31 2013 +0000

    Gracefully handle errors in logging config files

    Fixes bug #1154245

    If the parameter to the --log-config option cannot be loaded by the
    logging.config.fileConfig() function, you get an exception like this
    raised:

      NoSectionError: No section: 'formatters'

    which doesn't do much to help users understand the error.

    Improve the situation by wrapping the error in a custom exception type
    giving this:

     LogConfigError: Error loading logging config /etc/logging.conf: No section: 'formatters'

    Also add some tests to check we raise this error under the most common
    failure conditions.

    Change-Id: I6ad2eb4867213b6356ce43d75da50218d1b498f6

Changed in oslo:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in oslo:
milestone: none → havana-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in oslo:
milestone: havana-1 → 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.