do not use str in message object because they may contain non-ascii characters

Bug #1406728 reported by ZhiQiang Fan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
Medium
ZhiQiang Fan

Bug Description

INFO ceilometer.agent.base [-] Polling pollster network.services.lb.health_monitor in the context of meter_source
ERROR ceilometer.agent.base [-] Unable to discover resources: Message objects do not support str() because they may contain non-ascii characters. Please use unicode() or translate() instead.
TRACE ceilometer.agent.base Traceback (most recent call last):
TRACE ceilometer.agent.base File "/opt/stack/ceilometer/ceilometer/agent/base.py", line 272, in discover
TRACE ceilometer.agent.base discovered = discoverer.discover(self, param)
TRACE ceilometer.agent.base File "/opt/stack/ceilometer/ceilometer/agent/plugin_base.py", line 75, in func
TRACE ceilometer.agent.base str(keystone) if keystone else '')
TRACE ceilometer.agent.base File "/usr/local/lib/python2.7/dist-packages/oslo/i18n/_message.py", line 167, in __str__
TRACE ceilometer.agent.base raise UnicodeError(msg)
TRACE ceilometer.agent.base UnicodeError: Message objects do not support str() because they may contain non-ascii characters. Please use unicode() or translate() instead.
TRACE ceilometer.agent.base

Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

It happens when keystone is not avaiable, I will upload a patch soon

Changed in ceilometer:
assignee: nobody → ZhiQiang Fan (aji-zqfan)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (master)

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

Changed in ceilometer:
status: New → In Progress
Lianhao Lu (lianhao-lu)
Changed in ceilometer:
importance: Undecided → Low
importance: Low → Medium
milestone: none → kilo-2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (master)

Reviewed: https://review.openstack.org/144894
Committed: https://git.openstack.org/cgit/openstack/ceilometer/commit/?id=8e01978eb2a5ee041a1ae894e787a95487a77d7c
Submitter: Jenkins
Branch: master

commit 8e01978eb2a5ee041a1ae894e787a95487a77d7c
Author: ZhiQiang Fan <email address hidden>
Date: Mon Jan 5 02:50:36 2015 +0800

    remove unnecessary str method when log messages

    In Python 2 environment, if we use str(object) in log message, it
    will raise UnicodeError. And since we use string format in log
    messages, the explict str is a bit redundant too.

    See discussion in dev mailing list:
    http://lists.openstack.org/pipermail/openstack-dev/2014-June/038857.html

    See oslo.i18n source code:
    https://github.com/openstack/oslo.i18n/blob/1.1.0/oslo/i18n/_message.py#L159

    Change-Id: Ie9d086a49d56634496a8efbe37ea04f6812e561c
    Closes-Bug: #1406728

Changed in ceilometer:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in ceilometer:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: kilo-2 → 2015.1.0
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.