Can't close a watcher
See original GitHub issueHello,
It seems the client is unable to close the HTTP connection while watching the pod. Indeed, an “OkHttp” thread is still running, waiting for content of the kubernetes API. I suspect the following code to cause the problem:
public class WatchConnectionManager<T, L extends KubernetesResourceList> implements Watch {
...
Request request = new Request.Builder()
.get()
.url(httpUrlBuilder.build())
.addHeader("Origin", requestUrl.getProtocol() + "://" + requestUrl.getHost() + ":" + requestUrl.getPort())
.build();
clonedClient.setReadTimeout(0, TimeUnit.MILLISECONDS);
...
Indeed the timeout for the connection is set to 0, meaning there is no timeout at all.
Here is a minimal example of this problem (the program is still running after client.close() is displayed):
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.client.*;
public class Test {
public static void main(String[] args) {
KubernetesClient client = new DefaultKubernetesClient();
Watch watch = client.pods().inNamespace("default").watch(new Watcher<Pod>() {
public void eventReceived(Action action, Pod pod) {
System.out.println(pod.getMetadata().getResourceVersion());
}
public void onClose(KubernetesClientException e) {
System.out.println("client closed");
}
});
watch.close();
client.close();
System.out.println("client.close();");
}
}
EDIT: Tested with kubernetes-client v1.3.82
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Poll Watcher's Guide - the Texas Secretary of State
The integrity of elections is a concern of all citizens, and although poll watchers may represent particular candidates, political parties, or specific-purpose ...
Read more >Poll Watchers and Challengers
The table below lists state-by-state laws regarding poll watcher qualifications. Typically political parties, candidates, and ballot issue ...
Read more >Cannot add or remove watcher - K15t Help Center
An issue does not get synchronized and appears in the troubleshooting section with the category Cannot add or remove watcher. There can be...
Read more >Enabling and disabling System Watcher
By default, System Watcher is enabled and runs in the mode recommended by Kaspersky. You can disable System Watcher, if necessary.
Read more >Poll Watchers - Vote.PA.Gov
Each political party and political body which has nominated candidates on the ballot may appoint three poll watchers for each election district at...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ZenithKaizer Thanks for the info - will watch out for that. Wonder if it makes sense to have a timeout in the close somehow, although have to be careful of not leaking resources. Will think on that,
@jimmidyson we were using kubemark release with hollow-nodes to emulate real nodes for testing purposes : https://github.com/kubernetes/kubernetes/blob/release-1.2/docs/proposals/kubemark.md. All were performing well then, except for this
watch.close();
We just switch to standard kubernetes binairies and it works! Thanks …