question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't close a watcher

See original GitHub issue

Hello,

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:closed
  • Created 7 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jimmidysoncommented, Jun 10, 2016

@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,

0reactions
ZenithKaizercommented, Jun 10, 2016

@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 …

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found