No handler found if logging occurs before logging is ready

Bug #1516128 reported by Joe D'Andrea
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Low
Joe D'Andrea
oslo.log
Fix Released
Undecided
Joe D'Andrea

Bug Description

It's not unusual to see this pattern (e.g., for heat-api):

  logging.register_options(cfg.CONF)
  cfg.CONF(project='heat', prog='heat-api',
    version=version.version_info.version_string())

Let's say oslo_config discovers a deprecated option:

  if self.deprecated_for_removal and not self._logged_deprecation:
      self._logged_deprecation = True
      pretty_group = group_name or 'DEFAULT'
      LOG.warning('Option "%s" from group "%s" is deprecated for '
                  'removal. Its value may be silently ignored in the '
                  'future.', self.dest, pretty_group)

In this case it logs a warning ... except logging isn't ready yet (the default handlers aren't in place at this point), resulting in:

  No handlers could be found for logger "oslo_config.cfg"

After observing other kilo/liberty installations/upgrades, it looks like this is happening across a variety of projects. That means there are warnings and errors that aren't being surfaced.

Joe D'Andrea (jdandrea)
Changed in oslo.log:
assignee: nobody → Joe D'Andrea (joedandrea)
description: updated
description: updated
description: updated
Joe D'Andrea (jdandrea)
Changed in oslo.log:
status: New → Confirmed
status: Confirmed → In Progress
Revision history for this message
Joe D'Andrea (jdandrea) wrote :

Patch submitted for review:
https://review.openstack.org/#/c/245303

Changed in oslo.log:
assignee: Joe D'Andrea (joedandrea) → Davanum Srinivas (DIMS) (dims-v)
Revision history for this message
Joe D'Andrea (jdandrea) wrote :

Switching back per discussion w/dims and adjusting commit. (Thanks for your help on this, Davanum!)

Changed in oslo.log:
assignee: Davanum Srinivas (DIMS) (dims-v) → Joe D'Andrea (joedandrea)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.log (master)

Reviewed: https://review.openstack.org/245303
Committed: https://git.openstack.org/cgit/openstack/oslo.log/commit/?id=ed9d276af0a54807ebf0ddfb8c9dbafedae24db8
Submitter: Jenkins
Branch: master

commit ed9d276af0a54807ebf0ddfb8c9dbafedae24db8
Author: Joe D'Andrea <email address hidden>
Date: Fri Nov 13 19:23:50 2015 +0000

    Log to sys.stderr to avoid "No handlers could be found..."

    On occasion, logging can occur before logging is ready, resulting
    in unseen warnings/errors, for instance in oslo_config. To avoid
    this, we temporarily log to sys.stderr until things are ready.

    Change-Id: I9a3ce94881d1cdaddfe5a616dca0bdbf5326eddc
    Closes-Bug: 1516128

Changed in oslo.log:
status: In Progress → Fix Committed
Changed in oslo.log:
milestone: none → 2.0.0
status: Fix Committed → Fix Released
Joe D'Andrea (jdandrea)
Changed in heat:
assignee: nobody → Joe D'Andrea (joedandrea)
Joe D'Andrea (jdandrea)
Changed in heat:
status: New → Fix Released
status: Fix Released → Fix Committed
tags: added: liberty-backport-potential
Changed in heat:
milestone: none → mitaka-1
importance: Undecided → Low
Changed in heat:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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