Skip to content
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

ConfigMap watching drops connection silently #547

Closed
rametta opened this issue Jan 21, 2019 · 4 comments
Closed

ConfigMap watching drops connection silently #547

rametta opened this issue Jan 21, 2019 · 4 comments

Comments

@rametta
Copy link

rametta commented Jan 21, 2019

Hello,

I'm have an issue watching configMaps. After a while the connection will drop silently without any warning and the server will stop receiving updates through the ResultChan(). I've tried using TimeoutSeconds to keep the timeout to be much longer but it seems hacky to put a very large number there.

Is there any way to catch a dropped connection so i can schedule a reconnect?

Here is my code. Any insights will be helpful, thank you.

watcher, err := client.CoreV1().ConfigMaps(namespace).Watch(metav1.ListOptions{
  FieldSelector: fields.Set{"metadata.name": namespace + "-" + stage + "-config"}.AsSelector().String(),
  Watch:         true,
})

if err != nil {
  log.Fatalln(err.Error())
}

for event := range watcher.ResultChan() {
  fmt.Println("EVENT TYPE: ", event.Type)
  c := event.Object.(*v1.ConfigMap)
  configMap = c.Data
  fmt.Println("Updated config map")
}
@liggitt
Copy link
Member

liggitt commented Jan 22, 2019

when the connection drops, the result channel closes, and your code is responsible for re-establishing the watch

/close

@k8s-ci-robot
Copy link
Contributor

@liggitt: Closing this issue.

In response to this:

when the connection drops, the result channel closes, and your code is responsible for re-establishing the watch

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@alexec
Copy link

alexec commented Mar 4, 2020

@liggitt do you have an example of the code needed please?

@liggitt
Copy link
Member

liggitt commented Mar 4, 2020

you can use:

  • NewRetryWatcher if you want to guarantee you observe every watch event and terminate if it can't re-establish a dropped watch at exactly the dropped version
  • NewIndexerInformerWatcher if you want your watcher to continue getting updates even if it needs to reestablish/relist and there are missed watch events that occurred while the connection was dropped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants