python: Passing `follow=True` to `read_namespaced_pod_log` makes it never return
I’m trying to stream logs out of a running pod.
For a pod named ‘test’ running in the default namespace,
api = client.CoreV1Api()
api.read_namespaced_pod_log("test", "default")
returns the logs so far. But,
api = client.CoreV1Api()
api.read_namespaced_pod_log("test", "default", follow=True)
just never returns. I can’t use it with watch.Watch either since that seems to be for a very different purpose.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 22 (15 by maintainers)
Commits related to this issue
- Making watch work with read_namespaced_pod_log. Fixes https://github.com/kubernetes-client/python/issues/199. — committed to mitar/python-base by mitar 6 years ago
- Making watch work with read_namespaced_pod_log. Fixes https://github.com/kubernetes-client/python/issues/199. — committed to mitar/python-base by mitar 6 years ago
- Making watch work with read_namespaced_pod_log. Fixes https://github.com/kubernetes-client/python/issues/199. — committed to mitar/python-base by mitar 6 years ago
- Making watch work with read_namespaced_pod_log. Fixes https://github.com/kubernetes-client/python/issues/199. — committed to dudleyhunt86/python-base-repository-build by dudleyhunt86 6 years ago
Ah so what I did initially was close but the temporary fix that worked for me was -
I had to decode the output:
/edit the proper way to do it:
Having trouble using this, am i missing something?
v1 = client.CoreV1Api()w = watch.Watch()for e in w.stream(v1.read_namespaced_pod_log, name=pod, namespace=namespace, follow=True, tail_lines=1, limit_bytes=560, _preload_content=False): print(e)Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.7/site-packages/kubernetes/watch/watch.py", line 132, in stream resp = func(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 18538, in read_namespaced_pod_log (data) = self.read_namespaced_pod_log_with_http_info(name, namespace, **kwargs) File "/usr/local/lib/python3.7/site-packages/kubernetes/client/apis/core_v1_api.py", line 18576, in read_namespaced_pod_log_with_http_info " to method read_namespaced_pod_log" % key TypeError: Got an unexpected keyword argument 'watch' to method read_namespaced_pod_logPosted on stackoverflow if anyone wanted to answer!
I am looking through the tests and I may be able to help. Let me work through the watch routines and I’ll let you know. @mitar