Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Can't use watch with request 2.4.3 #41

Closed
jayme-github opened this issue Apr 21, 2016 · 3 comments
Closed

Can't use watch with request 2.4.3 #41

jayme-github opened this issue Apr 21, 2016 · 3 comments

Comments

@jayme-github
Copy link
Contributor

jayme-github commented Apr 21, 2016

I always get strange tracebacks like the following with requests==2.4.3 (debian jessie). Upgrading to jessie-backports version (2.8.1) fixed that for me.

2016-04-20 20:50:09,186 (urllib3.connectionpool._make_request) [DEBUG] "GET /api/v1/watch/nodes?resourceVersion=1152705 HTTP/1.1" 200 None
Traceback (most recent call last):
  File "/opt/path/watcher.py", line 111, in <module>
    main(args.output, args.context, args.targetPort)
  File "/opt/path/watcher.py", line 65, in main
    for event in wq.object_stream():
  File "/usr/local/lib/python2.7/dist-packages/pykube/query.py", line 135, in object_stream
    we = json.loads(line.decode("utf-8"))
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 369, in decode
    raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 1 column 3 - line 1 column 5 (char 2 - 4)
@brosner
Copy link
Contributor

brosner commented Apr 21, 2016

Hmm, odd. Is there any way you can provide more information about the object behind line 135 in query.py? What differs between the two versions?

@jayme-github
Copy link
Contributor Author

If I throw a print in here it just gives me 4 bytes of "something" like

2016-04-28 14:10:53,235 (requests.packages.urllib3.connectionpool._new_conn) [INFO] Starting new HTTPS connection (1): 130.211.76.234
2016-04-28 14:10:53,351 (requests.packages.urllib3.connectionpool._make_request) [DEBUG] "GET /api/v1/nodes HTTP/1.1" 200 None
2016-04-28 14:10:53,435 (requests.packages.urllib3.connectionpool._make_request) [DEBUG] "GET /api/v1/nodes HTTP/1.1" 200 None
2016-04-28 14:10:53,487 (requests.packages.urllib3.connectionpool._make_request) [DEBUG] "GET /api/v1/watch/nodes?resourceVersion=1758073 HTTP/1.1" 200 None
WatchQuery line: '15f9'
Traceback (most recent call last):
...

Of cause that changes from call to call.
Increased chunk_size for the r.iter_content/r.iter_lines shows that those 4 bytes are send prior to the json content:

15f9\r\n{"type":"MODIFIED","object":{"kind":"Node","apiVersion":"v1","metadata":...

Oldest/First working requests version is 2.7.0 that updated urllib to 1.10.4 (ee7389d). That has changed a lot of the chuncked response/stream code (did not look in detail). Best bet might be to rise requirement to requests>=2.7.0

@jayme-github
Copy link
Contributor Author

jayme-github commented Nov 17, 2016

"Fixed" with pushing requirement to requests>=2.12 in #95

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants