summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/wget.py
diff options
context:
space:
mode:
authorChris Laplante via bitbake-devel <bitbake-devel@lists.openembedded.org>2019-07-26 13:18:37 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-07-27 22:46:09 +0100
commit1a4e4fb6b0a9d54641bd4193e95311d1f822a9ca (patch)
treeedf6c80b0612fe53348a05fb77bf82736a4a349e /bitbake/lib/bb/fetch2/wget.py
parentbebeed310bfea80eea3e25481ae246fdc9052eb6 (diff)
downloadpoky-1a4e4fb6b0a9d54641bd4193e95311d1f822a9ca.tar.gz
bitbake: fetch2/wget: avoid 'maximum recursion depth' RuntimeErrors when handling 403 codes
The code says that some servers respond with 403 codes when they really mean 405 codes. But we still need to account for legitimate 403 codes. Before this change, I noticed that sstate mirror checking was taking a very long time when I purposely entered incorrect credentials into my .netrc file for our sstate mirror. Instrumenting the code, I discovered tracebacks like the following for every mirror access attempt: File "/home/laplante/yocto/sources/poky/meta/classes/sstate.bbclass", line 839, in checkstatus fetcher.checkstatus() File "/home/laplante/yocto/sources/poky/bitbake/lib/bb/fetch2/__init__.py", line 1736, in checkstatus ret = try_mirrors(self, self.d, ud, mirrors, True) File "/home/laplante/yocto/sources/poky/bitbake/lib/bb/fetch2/__init__.py", line 1077, in try_mirrors ret = try_mirror_url(fetch, origud, uds[index], ld, check) File "/home/laplante/yocto/sources/poky/bitbake/lib/bb/fetch2/__init__.py", line 979, in try_mirror_url found = ud.method.checkstatus(fetch, ud, ld) File "/home/laplante/yocto/sources/poky/bitbake/lib/bb/fetch2/wget.py", line 337, in checkstatus opener.open(r) File "/usr/lib/python3.5/urllib/request.py", line 472, in open response = meth(req, response) File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python3.5/urllib/request.py", line 504, in error result = self._call_chain(*args) File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain result = func(*args) File "/home/laplante/yocto/sources/poky/bitbake/lib/bb/fetch2/wget.py", line 280, in http_error_405 unverifiable=True)) File "/usr/lib/python3.5/urllib/request.py", line 472, in open response = meth(req, response) File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python3.5/urllib/request.py", line 504, in error result = self._call_chain(*args) File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain result = func(*args) File "/home/laplante/yocto/sources/poky/bitbake/lib/bb/fetch2/wget.py", line 280, in http_error_405 unverifiable=True)) ... (repeats until recursion depth is reached) Solution is to make sure we only attempt the GET request once when handling 403/405 error codes. (Bitbake rev: 18d4a31fdcec1f0e5d2199d6142f0ce833fca1a7) Signed-off-by: Chris Laplante <chris.laplante@agilent.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/wget.py')
-rw-r--r--bitbake/lib/bb/fetch2/wget.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index 0f71ee4eac..725586d2b5 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -257,13 +257,15 @@ class Wget(FetchMethod):
257 fp.read() 257 fp.read()
258 fp.close() 258 fp.close()
259 259
260 newheaders = dict((k, v) for k, v in list(req.headers.items()) 260 if req.get_method() != 'GET':
261 if k.lower() not in ("content-length", "content-type")) 261 newheaders = dict((k, v) for k, v in list(req.headers.items())
262 return self.parent.open(urllib.request.Request(req.get_full_url(), 262 if k.lower() not in ("content-length", "content-type"))
263 headers=newheaders, 263 return self.parent.open(urllib.request.Request(req.get_full_url(),
264 origin_req_host=req.origin_req_host, 264 headers=newheaders,
265 unverifiable=True)) 265 origin_req_host=req.origin_req_host,
266 266 unverifiable=True))
267
268 raise urllib.request.HTTPError(req, code, msg, headers, None)
267 269
268 # Some servers (e.g. GitHub archives, hosted on Amazon S3) return 403 270 # Some servers (e.g. GitHub archives, hosted on Amazon S3) return 403
269 # Forbidden when they actually mean 405 Method Not Allowed. 271 # Forbidden when they actually mean 405 Method Not Allowed.