Logging the request ID is incorrectly formatted on Python 3

Bug #1526662 reported by Victor Stinner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.context
Fix Released
Undecided
Unassigned

Bug Description

oslo.context provides a request identifier as a byte string and oslo.log uses it directly, without decoding it. As a result, oslo.log contains b'...' on Python 3. Example:

WARNING glance.api.v2.tasks [b'req-83a6...' 54492... - - -] ...

Even if it would be trivial to work around the issue in oslo.log, I consider that it's a major design issue in oslo.context. I propose to change the type of Context.request_id from bytes to str on Python 3. On Python 3, the str type is more "natural", whereas bytes causes various unexpected issues. For example, print("id: %s" % b'req-xx') raises a BytesWarning exception if Python 3 is run with python3 -bb.

Proposed change to fix oslo.context: https://review.openstack.org/#/c/250731/

This change is a deliberate break in the API, but only on Python 3. Today, services are not deployed with Python 3, so it's not like this change is going to break applications.

If we keep the request_id as a bytes string, we will have to fix *many* applications, not only oslo.log. For example, I found this bug when I tried to run Glance unit tests on Python 3 with python3 -bb to debug an issue specific to Python 3: https://review.openstack.org/#/c/250083/ (search for "python3 -bb" in comments)

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/oslo.context 2.0.0

This issue was fixed in the openstack/oslo.context 2.0.0 release.

Changed in oslo.context:
status: New → Fix Released
no longer affects: oslo.context/liberty
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.