-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing follow=True
to read_namespaced_pod_log
makes it never return
#199
Comments
It looks like I can pass |
Maybe we can add a |
+1 on adding it to Watch (or watch could special case this one?)
…On Wed, May 3, 2017 at 11:26 AM, Mehdy Bohlool ***@***.***> wrote:
Maybe we can add a follow method to Watch class to set "follow" flag
instead of "watch" and stream out strings instead of API objects. but
_preload_content need to be documented anyway.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#199 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAB23vyGNN2NrMePmgLy81a5qAVLm70Rks5r2Ma9gaJpZM4NIDE6>
.
--
Yuvi Panda T
http://yuvi.in/blog
|
I am just looking for somebody to do this. If nobody took it and I got free time (maybe not near future :) ), I will do it. |
|
@mbohlool Any update on this? I'd be happy to contribute but would need a few sentences as guideline. |
It would be nice if you can contribute. Here are the things need to be done:
Let me know if you need more. I will be happy to review the code when it is ready. |
I added "_preload_content=False" based on the official example , it still has no output. How can i get the the stream output |
FYI, |
I made a PR here: kubernetes-client/python-base#93 |
It works well, but I do not have an idea how can this API support resuming. So if the HTTP connection fails, it seems there is no real way to resume following the log from where you stopped. The only approach I can see is to require timestamp to be added to every line and then use that? |
Yeah for me neither @yuvipanda did you do something different from the above? |
Ah so what I did initially was close but the temporary fix that worked for me was - for line in client.CoreV1Api.read_namespaced_pod_log('<pod_name>', 'default', follow=True, _preload_content=False).stream():
print(line) |
@roycaihw Why was this labeled with "help wanted"? There is already a PR for this. |
@mitar I was doing a blind conversion from our custom Thanks for fixing this! I see Yu was already reviewing that PR so I will leave it to him. Please let me know if you need anything from me. |
Ah, that makes it clearer. Yes, that PR was reviewed, I have to figure how to make tests though. I looked briefly but it wasn't exactly clear to me. If anyone here has any spare cycles, it would be helpful if you could help me improving that PR by adding tests. I can add you to my fork repo to contribute if you want. |
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 |
Watch may not be the correct way to handle live streaming logs. Hope I am not making mistakes here, and i will try to write a PR for this. |
@zq-david-wang There are two ways here. One is if you want to handle streaming yourself, but there is also So maybe there is something more one could do to improve things here for cases where you do not want to use |
I have added tests to kubernetes-client/python-base#93. I also opened kubernetes-client/python-base#117. I really think tests should be using proper Kubernetes cluster inside CI and not mocked messages. Because now the author of the code both writes the code and test messages, but there is really not any assurance that test messages align with real Kubernetes messages. |
Having trouble using this, am i missing something?
Posted on stackoverflow if anyone wanted to answer! |
I had to decode the output: for line in v1.read_namespaced_pod_log(<pod-ame>,<namespace>,follow = True, _preload_content=False).stream():
print(line.decode('utf-8')) /edit from kubernetes import watch
w = watch.Watch()
for line in w.stream(v1.read_namespaced_pod_log, name=<pod-name>, namespace='<namespace>'):
log.info(line) |
I'm trying to stream logs out of a running pod.
For a pod named 'test' running in the default namespace,
returns the logs so far. But,
just never returns. I can't use it with
watch.Watch
either since that seems to be for a very different purpose.The text was updated successfully, but these errors were encountered: