cname_lookup middleware save a wrong type string in environment that causes 500 error

Bug #1862115 reported by Charles Hsu
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Object Storage (swift)
Fix Released
High
Unassigned

Bug Description

$ curl -i http://demo_resources.sjc.chhsu.com/test.txt

HTTP/1.1 200 OK
Content-Length: 10
Content-Type: text/plain
Accept-Ranges: bytes
Last-Modified: Thu, 06 Feb 2020 04:34:23 GMT
Etag: b05403212c66bdc8ccc597fedf6cd5fe
X-Timestamp: 1580963662.95064
X-Object-Meta-Mtime: 1580963560.279146
X-Trans-Id: tx7be3027196ee458fb754c-005e3b9a85
X-Openstack-Request-Id: tx7be3027196ee458fb754c-005e3b9a85
Date: Thu, 06 Feb 2020 04:48:06 GMT

test file

$ curl -i http://demo_resources.sjc.chhsu.com/test.txt

HTTP/1.1 500 Internal Error
Content-Length: 17
Content-Type: text/plain
X-Openstack-Request-Id: tx550f2011d86c472e9f79c-005e3b9a92
X-Trans-Id: tx550f2011d86c472e9f79c-005e3b9a92
Date: Thu, 06 Feb 2020 04:48:19 GMT

An error occurred

[root@demo60 middleware]# grep tx7be3027196ee458fb754c-005e3b9a85 /var/log/swift/all.log.1
Feb 6 04:48:06 demo60 proxy-server: Mapped demo_resources.sjc.chhsu.com to resources.demo.swift.chhsu.com (txn: tx7be3027196ee458fb754c-005e3b9a85)
Feb 6 04:48:06 demo60 object-server: 192.168.190.60 - - [06/Feb/2020:04:48:06 +0000] "GET /d2/46157/AUTH_demo/resources/test.txt" 200 10 "GET http://resources.demo.swift.chhsu.com/v1/AUTH_demo/resources/test.txt" "tx7be3027196ee458fb754c-005e3b9a85" "proxy-server 8770" 0.0033 "-" 3574 0
Feb 6 04:48:06 demo60 proxy-server: 192.168.190.1 192.168.190.1 06/Feb/2020/04/48/06 GET /v1/AUTH_demo/resources/test.txt HTTP/1.0 200 - curl/7.64.1 - - 10 - tx7be3027196ee458fb754c-005e3b9a85 X-Backend-Etag-Is-At:%20x-object-sysmeta-slo-etag%0AUser-Agent:%20curl/7.64.1%0AX-Trans-Id:%20tx7be3027196ee458fb754c-005e3b9a85%0AX-Backend-Storage-Policy-Index:%200%0AHost:%20resources.demo.swift.chhsu.com%0AAccept:%20%2A/%2A%0AContent-Type:%20 0.3750 - - 1580964485.809938908 1580964486.184923887 0

[root@demo60 middleware]# grep tx550f2011d86c472e9f79c-005e3b9a92 /var/log/swift/all.log.1
Feb 6 04:48:18 demo60 proxy-server: Mapped demo_resources.sjc.chhsu.com to resources.demo.swift.chhsu.com (txn: tx550f2011d86c472e9f79c-005e3b9a92)
Feb 6 04:48:19 demo60 proxy-server: ERROR Unhandled exception in request:
Traceback (most recent call last):
  File "/opt/ss/lib/python2.7/site-packages/swift/proxy/server.py", line 487, in handle_request
    controller, path_parts = self.get_controller(req)
  File "/opt/ss/lib/python2.7/site-packages/swift/proxy/server.py", line 394, in get_controller
    if req.path == '/info':
  File "/opt/ss/lib/python2.7/site-packages/swift/common/swob.py", line 1037, in path
    self.environ['PATH_INFO'])
  File "/opt/ss/lib/python2.7/site-packages/swift/common/swob.py", line 300, in wsgi_quote
    raise TypeError('Expected a WSGI string; got %r' % wsgi_str)
TypeError: Expected a WSGI string; got u'/v1/AUTH_demo/resources/test.txt' (txn: tx550f2011d86c472e9f79c-005e3b9a92)
Feb 6 04:48:19 demo60 proxy-server: Error: An error occurred:
Traceback (most recent call last):
  File "/opt/ss/lib/python2.7/site-packages/swift/common/middleware/catch_errors.py", line 75, in handle_request
    resp = self._app_call(env)
  File "/opt/ss/lib/python2.7/site-packages/swift/common/wsgi.py", line 1223, in _app_call
    resp = reiterate(resp)
  File "/opt/ss/lib/python2.7/site-packages/swift/common/utils.py", line 3900, in reiterate
    chunk = next(iterator)
  File "/opt/ss/lib/python2.7/site-packages/swift/common/middleware/proxy_logging.py", line 383, in iter_response
    metric_name = self.statsd_metric_name(req, status_int, method)
  File "/opt/ss/lib/python2.7/site-packages/swift/common/middleware/proxy_logging.py", line 308, in statsd_metric_name
    stat_type = self.get_metric_name_type(req)
  File "/opt/ss/lib/python2.7/site-packages/swift/common/middleware/proxy_logging.py", line 297, in get_metric_name_type
    if req.path.startswith('/v1/'):
  File "/opt/ss/lib/python2.7/site-packages/swift/common/swob.py", line 1037, in path
    self.environ['PATH_INFO'])
  File "/opt/ss/lib/python2.7/site-packages/swift/common/swob.py", line 300, in wsgi_quote
    raise TypeError('Expected a WSGI string; got %r' % wsgi_str)
TypeError: Expected a WSGI string; got u'/v1/AUTH_demo/resources/test.txt' (txn: tx550f2011d86c472e9f79c-005e3b9a92)

summary: - cname_lookup stored wrong type in environment
+ cname_lookup middleware save a wrong type string in environment that
+ causes 500 error
Tim Burke (1-tim-z)
Changed in swift:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (master)

Reviewed: https://review.opendev.org/706187
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=61bf5ee1c428410b70bfab0a6eae361df948d03e
Submitter: Zuul
Branch: master

commit 61bf5ee1c428410b70bfab0a6eae361df948d03e
Author: Charles Hsu <email address hidden>
Date: Thu Feb 6 15:35:11 2020 +0800

    Ensure domain stored in memcached gets utf8 decoded on py2

    Change-Id: I73b5af9645f3f7349144384609bf18a79620e92f
    Closes-Bug: #1862115

Changed in swift:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/710904

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/710905

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (stable/train)

Reviewed: https://review.opendev.org/710904
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=4be20e0d8c77d2bb9dbc163b504a977208d9a6b6
Submitter: Zuul
Branch: stable/train

commit 4be20e0d8c77d2bb9dbc163b504a977208d9a6b6
Author: Charles Hsu <email address hidden>
Date: Thu Feb 6 15:35:11 2020 +0800

    Ensure domain stored in memcached gets utf8 decoded on py2

    Change-Id: I73b5af9645f3f7349144384609bf18a79620e92f
    Closes-Bug: #1862115
    (cherry picked from commit 61bf5ee1c428410b70bfab0a6eae361df948d03e)

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (stable/stein)

Reviewed: https://review.opendev.org/710905
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=24bb15c2914c23b02c801eb29e3da452b81ebf3d
Submitter: Zuul
Branch: stable/stein

commit 24bb15c2914c23b02c801eb29e3da452b81ebf3d
Author: Charles Hsu <email address hidden>
Date: Thu Feb 6 15:35:11 2020 +0800

    Ensure domain stored in memcached gets utf8 decoded on py2

    Change-Id: I73b5af9645f3f7349144384609bf18a79620e92f
    Closes-Bug: #1862115
    (cherry picked from commit 61bf5ee1c428410b70bfab0a6eae361df948d03e)

tags: added: in-stable-stein
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to swift (feature/losf)

Fix proposed to branch: feature/losf
Review: https://review.opendev.org/713632

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to swift (feature/losf)
Download full text (40.5 KiB)

Reviewed: https://review.opendev.org/713632
Committed: https://git.openstack.org/cgit/openstack/swift/commit/?id=79bd2e59e5c15ee84814ec1c4f0893176ba79412
Submitter: Zuul
Branch: feature/losf

commit f2ffd900593db2829a39a073f0c033d82985c40f
Author: Clay Gerrard <email address hidden>
Date: Fri Feb 28 11:09:51 2020 -0600

    Apply limit to list versioned containers

    Change-Id: I28e062273d673c4f07cd3c5da088aa790b77a599
    Closes-Bug: #1863841

commit dc40779307095b8d0b2761b77b9cb2904ec721ae
Author: Clay Gerrard <email address hidden>
Date: Fri Feb 28 10:00:25 2020 -0600

    Use float consistently for proxy timeout settings

    Change-Id: I433c97df99193ec31c863038b9b6fd20bb3705b8

commit 55049beda5b9d7038a3604a87f28312d7702ccb2
Author: Tim Burke <email address hidden>
Date: Fri Feb 28 18:59:32 2020 -0800

    tests: Use timedelta to adjust dates, not string manipulations

    Change-Id: I8f65ccd7f2a79d5b877bfbef0274fb7857e21391

commit 3b65a5998cc921d2763cf1a9ec1e40b88491262d
Author: Tim Burke <email address hidden>
Date: Wed Jan 10 06:16:41 2018 +0000

    Fix up some Content-Type handling in account/container listings

    Update content type on 204 (not just 200) to properly handle HEAD
    requests from xml/txt listings.

    Add "Vary: Accept" header to listings, since otherwise, browsers may
    serve the wrong content type from cache (even though we *would have*
    sent the *right* type if it actually sent the request).

    Change-Id: Iaa333aaca36a8dc2df65d38ef2173e3a6e2000ee

commit ecca23eb806e11cf6517f0456483da7a065350a8
Author: Clay Gerrard <email address hidden>
Date: Fri Feb 21 15:33:21 2020 -0600

    Extend eventlet_debug logging to GreenAsyncPile

    Change-Id: Ibd9fe5c9a1e75b86eb7d540594d5cf516758e17e

commit 0fb3371484f1d0f629d0b0e33f6aafbff0e43ee9
Author: Sam Morrison <email address hidden>
Date: Tue Feb 18 10:17:50 2020 +1100

    Delay importing swiftclient until after monkey-patching

    Commit message below partly copied from nova:

    Eventlet monkey patching should be as early as possible

    We were seeing infinite recursion opening an ssl socket when running
    various combinations of python3, eventlet, and urllib3. It is not
    clear exactly what combination of versions are affected, but for
    background there is an example of this issue documented here:

    https://github.com/eventlet/eventlet/issues/371

    The immediate cause in swift's case was that we were calling
    eventlet.monkey_patch() after importing swiftclient (which imported
    requests, which finally imported urllib3).

    We only use the imported function in one place, however; hold off on
    importing until we actually need it to ensure that monkey patching
    happens first. Note that we *don't* want to monkey-patch at import time,
    as we've previously had bugs related to import-time side-effects.

    Change-Id: I24f4bcc3d62dc37fd9559032bfd25f5b15f98745
    Closes-bug: #1863680
    Related-bug: #1380815

commit a5afe767581d2cb97cf3690067e6d626c7682c2c
Author: Tim Burke <email address hidden>
Date: Wed Feb 19 10:09:49 2020 -0800

    Revert "Make roll...

tags: added: in-feature-losf
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/swift stein-eol

This issue was fixed in the openstack/swift stein-eol 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.