Page MenuHomePhabricator

SwiftMedia URL rewrite returns some 404s with wrong Content-Length
Closed, ResolvedPublic

Description

Due to a bug in rewrite.py, certain 404s sent by ms-fe hosts are returned with Content-Length: 69 while the actual content length is 9, len("Not Found").

For example:

$ curl -v https://swift-rw.discovery.wmnet/wikipedia/commons/thumb/6/60/K
< HTTP/1.1 404 Not Found
[...]
< Content-Type: text/html; charset=UTF-8
< Content-Length: 69
[...]
curl: (18) transfer closed with 60 bytes remaining to read
Not Found

This causes various issues at the CDN layer resulting in 503 errors.

It seems that the problem is at line 94:

return swob.HTTPException(status=status, body=error.msg, headers=error.hdrs.items())

The body is set to the error message (probably the string "Not Found"?), while the list of headers, including Content-Length, is passed as-is from Thumbor. Indeed, 69 is the length of the Thumbor response:

$ curl -v http://thumbor.svc.eqiad.wmnet:8800/wikipedia/commons/thumb/6/60/K
< HTTP/1.1 404 Not Found
[...]
< Content-Length: 69
[...]
<html><title>404: Not Found</title><body>404: Not Found</body></html>

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
ema triaged this task as Medium priority.Apr 29 2019, 1:50 PM

Change 507307 had a related patch set uploaded (by Gilles; owner: Gilles):
[operations/puppet@production] Proxy Thumbor 404s as-is

https://gerrit.wikimedia.org/r/507307

I'm wondering if the underlying issue here (copying responses inside rewrite.py) could be the culprit for T219635: swift falsely claims 404s are gzipped too.

Change 507307 merged by Ema:
[operations/puppet@production] Proxy Thumbor errors as-is

https://gerrit.wikimedia.org/r/507307

Mentioned in SAL (#wikimedia-operations) [2019-05-02T12:01:03Z] <ema> restart swift-proxy on ms-fe1005 T222071

This is now fixed, CL matches the actual body length:

$ curl -v http://swift-rw.discovery.wmnet/wikipedia/commons/thumb/6/60/K 
[...]
< HTTP/1.1 404 Not Found
[...]
< Content-Length: 69
[...]
<html><title>404: Not Found</title><body>404: Not Found</body></html>

The recurring 503s in ulsfo caused by this are finally gone:

Screenshot from 2019-05-02 14-24-11.png (1×2 px, 276 KB)