-
Notifications
You must be signed in to change notification settings - Fork 74
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
Reconnect watcher if server ends empty response #96
Reconnect watcher if server ends empty response #96
Conversation
It looks like this behavior was introduced in 61852ea, as part of #22. @olitheolix, could you clarify why the asyncio watcher should stop if the server has responded with an empty response? From my perspective, it seems like it'd be better if the watcher remained connected (reconnect) unless the user had specified a timeout. I just want to be sure I'm not missing something... I notice that three test cases are failing - I'll address these as soon as I understand the above. |
@JacobHenner From what I can remember, it was about the separation of concerns. The function should only deal with the current event stream and return once K8s closed that stream. The caller can then implement the desired retry/reconnect/whatever logic itself. That, at least, is how I did it In my personal version of the In other words, no, I do not think you are missing anything here. |
I'd like to keep this client similar to the official client as possible. Are we sure that empty line means that server is disconnected? I don't see such checks in the official client. |
Ah, I see. From my perspective, the library should be responsible for maintaining the connection unless a user-specified timeout has elapsed or the server has responded with some sort of error condition. I've seen other comments that lead me to believe this is the expected behavior from a client - kubernetes/kubernetes#6513 (comment), for example.
It looks like it could mean a few things - https://github.com/kubernetes/kubernetes/blob/79e1ad2f4bbd05b1e56b7b57b63b2c1d67b90156/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/watch.go#L212-L261
In the official Python client: When iter_resp_lines(resp) returns a value which evaluates to False (e.g. the k8s api returns an empty response), iteration stops. Unless _stop has been set to True, the client will attempt to reconnect. |
I got it, the official client "ignore" empty lines. In my opinion it's better if a library does mandatory retries to simplify end-client's code. |
Should I adjust the tests accordingly? |
Yes, It'd be great. |
f91be13
to
eed4040
Compare
If the server sends an empty response (e.g. a server-side timeout was exceeded), the watcher should reconnect unless the user has specified a timeout. This is similar to the behavior in the standard Python Kubernetes library.
eed4040
to
ff5894a
Compare
Codecov Report
@@ Coverage Diff @@
## master #96 +/- ##
=========================================
Coverage ? 93.31%
=========================================
Files ? 23
Lines ? 1585
Branches ? 0
=========================================
Hits ? 1479
Misses ? 106
Partials ? 0
Continue to review full report at Codecov.
|
Is there any progress on this PR? |
It's been solved in the latest version v30.3.0. |
If the server sends an empty response (e.g. a server-side timeout was
exceeded), the watcher should reconnect unless the user has specified a
timeout. This is similar to the behavior in the standard Python
Kubernetes library.
Fixes #95