fail to upload object if swift proxy-server is deployed in apache 2.4

Bug #1400770 reported by LIU Yulong
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Undecided
LIU Yulong

Bug Description

fail to upload object if swift proxy-server is deployed in apache 2.4:

Environment:

Ubuntu 14.04.1 LTS

horizon (github master branch source code install)
python-swiftclient (github master branch source code install)
swift (github master branch source code install)

Apache/2.4.7 log:
[Sun Dec 07 00:26:55.329422 2014] [:error] [pid 18608:tid 140692826650368] WARNING:urllib3.connectionpool:HttpConnectionPool is full, discarding connection: 192.168.1.151
[Sun Dec 07 00:26:55.329525 2014] [:error] [pid 18608:tid 140692826650368] REQ: curl -i http://192.168.1.151:8080/v1/AUTH_faf24933fa804ece91c2da2afdfa4127/testestset/setup.py -X PUT -H "X-Auth-Token: 312a22b6c61b43e08455303003fc72a0"
[Sun Dec 07 00:26:55.329935 2014] [:error] [pid 18608:tid 140692826650368] RESP STATUS: 411 Length Required
[Sun Dec 07 00:26:55.330003 2014] [:error] [pid 18608:tid 140692826650368] RESP HEADERS: [('date', 'Sat, 06 Dec 2014 16:26:55 GMT'), ('content-length', '318'), ('content-type', 'text/html; charset=iso-8859-1'), ('connection', 'close'), ('server', 'Apache/2.4.7 (Ubuntu)')]
[Sun Dec 07 00:26:55.330050 2014] [:error] [pid 18608:tid 140692826650368] RESP BODY: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
[Sun Dec 07 00:26:55.330058 2014] [:error] [pid 18608:tid 140692826650368] <html><head>
[Sun Dec 07 00:26:55.330063 2014] [:error] [pid 18608:tid 140692826650368] <title>411 Length Required</title>
[Sun Dec 07 00:26:55.330068 2014] [:error] [pid 18608:tid 140692826650368] </head><body>
[Sun Dec 07 00:26:55.330073 2014] [:error] [pid 18608:tid 140692826650368] <h1>Length Required</h1>
[Sun Dec 07 00:26:55.330078 2014] [:error] [pid 18608:tid 140692826650368] <p>A request of the requested method PUT requires a valid Content-length.<br />
[Sun Dec 07 00:26:55.330083 2014] [:error] [pid 18608:tid 140692826650368] </p>
[Sun Dec 07 00:26:55.330088 2014] [:error] [pid 18608:tid 140692826650368] <hr>
[Sun Dec 07 00:26:55.330093 2014] [:error] [pid 18608:tid 140692826650368] <address>Apache/2.4.7 (Ubuntu) Server at 192.168.1.151 Port 8080</address>
[Sun Dec 07 00:26:55.330098 2014] [:error] [pid 18608:tid 140692826650368] </body></html>
[Sun Dec 07 00:26:55.330103 2014] [:error] [pid 18608:tid 140692826650368]
[Sun Dec 07 00:26:55.330295 2014] [:error] [pid 18608:tid 140692826650368] Object PUT failed: http://192.168.1.151:8080/v1/AUTH_faf24933fa804ece91c2da2afdfa4127/testestset/setup.py 411 Length Required [first 60 chars of response] <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
[Sun Dec 07 00:26:55.330306 2014] [:error] [pid 18608:tid 140692826650368] <html><he
[Sun Dec 07 00:26:55.330312 2014] [:error] [pid 18608:tid 140692826650368] Traceback (most recent call last):
[Sun Dec 07 00:26:55.330317 2014] [:error] [pid 18608:tid 140692826650368] File "/home/yulong/openstack/python-swiftclient/swiftclient/client.py", line 1241, in _retry
[Sun Dec 07 00:26:55.330322 2014] [:error] [pid 18608:tid 140692826650368] rv = func(self.url, self.token, *args, **kwargs)
[Sun Dec 07 00:26:55.330327 2014] [:error] [pid 18608:tid 140692826650368] File "/home/yulong/openstack/python-swiftclient/swiftclient/client.py", line 1014, in put_object
[Sun Dec 07 00:26:55.330332 2014] [:error] [pid 18608:tid 140692826650368] http_response_content=body)
[Sun Dec 07 00:26:55.330338 2014] [:error] [pid 18608:tid 140692826650368] ClientException: Object PUT failed: http://192.168.1.151:8080/v1/AUTH_faf24933fa804ece91c2da2afdfa4127/testestset/setup.py 411 Length Required [first 60 chars of response] <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
[Sun Dec 07 00:26:55.330343 2014] [:error] [pid 18608:tid 140692826650368] <html><he
[Sun Dec 07 00:26:55.330503 2014] [:error] [pid 18608:tid 140692826650368] Recoverable error: Object PUT failed: http://192.168.1.151:8080/v1/AUTH_faf24933fa804ece91c2da2afdfa4127/testestset/setup.py 411 Length Required [first 60 chars of response] <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
[Sun Dec 07 00:26:55.330525 2014] [:error] [pid 18608:tid 140692826650368] <html><he

cli test log:

curl -i http://192.168.1.151:8080/v1/AUTH_faf24933fa804ece91c2da2afdfa4127/testestset/setup.py -X PUT -H "X-Auth-Token: 312a22b6c61b43e08455303003fc72a0"

HTTP/1.1 411 Length Required
Date: Sat, 06 Dec 2014 16:41:14 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Trans-Id: tx0bff2b699baa499baddbd-00548331aa
Content-Length: 30
Connection: close
Content-Type: text/plain

Missing Content-Length header.

Horizon Code:
openstack_dashboard/dashboards/swift.py:
def swift_upload_object(request, container_name, object_name,
                        object_file=None):
    headers = {}
    size = 0
    if object_file:
        headers['X-Object-Meta-Orig-Filename'] = object_file.name
        size = object_file.size

LIU Yulong (dragon889)
summary: - fail to upload object if swift proxy-server is in apache 2.4
+ fail to upload object if swift proxy-server is deployed in apache 2.4
description: updated
description: updated
Changed in horizon:
assignee: nobody → LIU Yulong (dragon889)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

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

Changed in horizon:
status: New → In Progress
Revision history for this message
Tihomir Trifonov (ttrifonov) wrote :

It seems more like a misconfiguration of the swift proxy rather than problem in swiftclient...

Revision history for this message
LIU Yulong (dragon889) wrote :

Hi Tihomir Trifonov, I can also reproduce the problem in apache 2.2. According to this solution http://stackoverflow.com/questions/12091067/handling-http-chunked-encoding-with-django,
I set the WSGIChunkedRequest On. But swift got another error "Requested content-length of 9223372036854775807 is larger than the configured limit of 5368709122". But the upload file is very small. The configuration of swift proxy-server for apache, please see source code here: https://github.com/openstack/swift/tree/master/examples/apache2

Revision history for this message
Tihomir Trifonov (ttrifonov) wrote :

Let's first examine what happens here:

https://github.com/openstack/python-swiftclient/blob/master/swiftclient/client.py#L981

If there is a problem with sending Content-Length, it should be fixed in swiftclient and not in api/swift.py in Horizon.

Revision history for this message
LIU Yulong (dragon889) wrote :

Hi, it seems that swiftclient get a none Content-Length. Code: L969 to L974
Then code will goto:
        if content_length is None:
            def chunk_reader():
                while True:
                    data = contents.read(chunk_size)
                    if not data:
                        break
                    yield data
            conn.putrequest(path, headers=headers, data=chunk_reader())

Revision history for this message
LIU Yulong (dragon889) wrote :

After all this is really a horizon bug, fixed by this: https://bugs.launchpad.net/horizon/+bug/1352256

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on horizon (master)

Change abandoned by LIU Yulong (<email address hidden>) on branch: master
Review: https://review.openstack.org/140376
Reason: This patch fix this:
https://review.openstack.org/#/c/185403

LIU Yulong (dragon889)
no longer affects: python-swiftclient
Changed in horizon:
status: In Progress → Fix Released
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.