Logging of the gzipped body can be failed

Bug #1670620 reported by Vitalii Gridnev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-swiftclient
Fix Released
Undecided
Unassigned

Bug Description

2017-03-02T20:18:59.661653+00:00 node-1 glance-api: 2017-03-02 20:18:59.658 20687 DEBUG swiftclient [req-529764cb-284d-4c4a-ba84-acd6b720c45f 2b43ef59fda541b68bba7d60c26a0ee1 36a79e
095bea4dbeaa589008076f5033 - default default] REQ: curl -i http://10.109.1.9:8080/swift/v1/glance?format=json&prefix=4f81d888-6e65-4cf5-81da-4f86f2e1fb97- -X GET -H "Accept-Encoding
: gzip" -H "X-Auth-Token: gAAAAABYuH4zi6N_..." http_log /usr/lib/python2.7/dist-packages/swiftclient/client.py:164
2017-03-02T20:18:59.661855+00:00 node-1 glance-api[20416]: Traceback (most recent call last):
2017-03-02T20:18:59.661952+00:00 node-1 glance-api[20416]: File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit
2017-03-02T20:18:59.662042+00:00 node-1 glance-api[20416]: msg = self.format(record)
2017-03-02T20:18:59.662138+00:00 node-1 glance-api[20416]: File "/usr/lib/python2.7/logging/__init__.py", line 734, in format
2017-03-02T20:18:59.662209+00:00 node-1 glance-api[20416]: return fmt.format(record)
2017-03-02T20:18:59.662287+00:00 node-1 glance-api[20416]: File "/usr/lib/python2.7/dist-packages/oslo_log/formatters.py", line 297, in format
2017-03-02T20:18:59.662370+00:00 node-1 glance-api[20416]: return logging.Formatter.format(self, record)
2017-03-02T20:18:59.662440+00:00 node-1 glance-api[20416]: File "/usr/lib/python2.7/logging/__init__.py", line 476, in format
2017-03-02T20:18:59.662508+00:00 node-1 glance-api[20416]: raise e
2017-03-02T20:18:59.662577+00:00 node-1 glance-api[20416]: UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 12: ordinal not in range(128)

Revision history for this message
Tim Burke (1-tim-z) wrote :

Ugh, I never should have even tried with https://github.com/openstack/python-swiftclient/commit/f728027 -- API responses are so tiny, there's practically no benefit to gzipping, it just burns CPU :-/

I'm not clear on why anything's getting decoded, though -- it looks like this is py2, so we're trying to interpolate bytes into bytes. What version of oslo.log is that? Following https://github.com/openstack/oslo.log/commit/991d8f0 (or its mitaka counterpart, https://github.com/openstack/oslo.log/commit/a2e7f65) I thought that should Just Work™? It won't be particularly pretty, but it shouldn't go raising UnicodeErrors...

Regardless, something like https://review.openstack.org/#/c/442342/ will be necessary, or py3 logging (which *would* have record.msg as unicode) will break like this.

Revision history for this message
clayg (clay-gerrard) wrote :

to be 100% clear - is the "bug" here just that attempting to log a gzipped response might throw a traceback? Or that we *want* a gzipped body to be decoded to plaintext to log it?

Obviously we can't expect a gzipped body to make it's way to a terminal w/o some risk of malformed encoding... so un-gzipping it (maybe with some logging text to indicate it's was gzip on the wire) seems like a very reasonable path forward?

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-swiftclient (master)

Reviewed: https://review.openstack.org/442342
Committed: https://git.openstack.org/cgit/openstack/python-swiftclient/commit/?id=028c4824d0190e0b605ae9c90756167083e46cd3
Submitter: Jenkins
Branch: master

commit 028c4824d0190e0b605ae9c90756167083e46cd3
Author: Vitaly Gridnev <email address hidden>
Date: Tue Mar 7 13:38:22 2017 +0400

    Fix logging of the gzipped body

    Change-Id: I6d7ccbf4ef9b46e890ecec58842c5cdd2804c7a9
    Closes-bug: 1670620

Changed in python-swiftclient:
status: New → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-swiftclient (stable/ocata)

Fix proposed to branch: stable/ocata
Review: https://review.openstack.org/443047

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-swiftclient (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/443048

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-swiftclient (stable/ocata)

Change abandoned by Vitaly Gridnev (<email address hidden>) on branch: stable/ocata
Review: https://review.openstack.org/443047

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-swiftclient (stable/newton)

Change abandoned by Vitaly Gridnev (<email address hidden>) on branch: stable/newton
Review: https://review.openstack.org/443048

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-swiftclient 3.4.0

This issue was fixed in the openstack/python-swiftclient 3.4.0 release.

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.