Logging the request ID is incorrectly formatted on Python 3
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:/
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:/
Changed in oslo.context: | |
status: | New → Fix Released |
no longer affects: | oslo.context/liberty |
This issue was fixed in the openstack/ oslo.context 2.0.0 release.