-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Watcher stuck forever in a case of network disconnect #1148
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
Comments
This seems to be related to #868 |
cc @alanjcastonguay |
Yeah, this is one of the failure modes that prompted #868. But I still don't have a method to fix it, other than simply setting a client-side timeout. Did you have one set in this test? Can you paste a minimal example that reproduces the problem in your test? |
@alanjcastonguay It works like that always for me. The minimal code is trivial from kubernetes import client, watch
from datetime import datetime
watcher = watch.Watch()
func = client.CoreV1Api(client.ApiClient(client.Configuration())).list_namespaced_pod
kwargs = dict()
kwargs['timeout_seconds'] = 60
try:
while True:
for event in watcher.stream(func, **kwargs):
watcher_last_time_alive = datetime.now()
print(watcher_last_time_alive)
except Exception as e:
logging.error("API request failed", extra={
"API": "Kubernetes",
"method": func,
"kwargsGiven": kwargs,
"error": str(e)
}) |
This problem can be repeated in the case of unstable network environment. The more unstable the network, the more likely it is to have problems |
|
@alanjcastonguay Thank you for clarification! When I add |
The value is provided to a python/kubernetes/client/rest.py Lines 141 to 147 in 02ef5be
|
@alanjcastonguay Yep, my bad, forgot to remove my reconnect 5 seconds sleep |
/remove-kind bug Ok to close this? |
@alanjcastonguay After adding
It got all the events and then dies with that error after My {"_request_timeout": 90, "timeout_seconds": 3600} |
The urllib3 client timeout describes maximum seconds since last received byte. And the kubernetes API-server doesn't transmit any bytes if there's no changes to the watched collection. If you keep changing the set of pods at least every 90 seconds, the connection should remain up. |
@alanjcastonguay Yes, it works like that. I already have own implementation of such behaviour, though. |
Hi Nik, is this issue resolved? I got the same error. Thanks, Jeff |
@xuejiezhang Hi, This is the expected behavior. I've made own implementation of the reconnect, nothing else to do here until #868 closed. |
What happened (please include outputs or screenshots):
If the network to Kubernetes API disconnects, watcher just gets stuck forever with no exception.
What you expected to happen:
Watcher should raise an exception in a case of any network issues.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
kubectl version
): 1.17.0python --version
): 3.7pip list | grep kubernetes
): 11.0.0The text was updated successfully, but these errors were encountered: