Commit Graph

64 Commits

Author SHA1 Message Date
Kubernetes Submit Queue
68ca638164 Merge pull request #35672 from zlabjp/fix-list-and-watch-goroutine-leak
Automatic merge from submit-queue

Fix resync goroutine leak in ListAndWatch

<!--  Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, read our contributor guidelines https://github.com/kubernetes/kubernetes/blob/master/CONTRIBUTING.md and developer guide https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md
2. If you want *faster* PR reviews, read how: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/faster_reviews.md
3. Follow the instructions for writing a release note: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes
-->

**What this PR does / why we need it**:

This PR fixes resync goroutine leak in ListAndWatch function

**Which issue this PR fixes** _(optional, in `fixes #<issue number>(, #<issue_number>, ...)` format, will close that issue when PR gets merged)_: fixes #

fixes #35015

**Special notes for your reviewer**:

**Release note**:

<!--  Steps to write your release note:
1. Use the release-note-* labels to set the release note state (if you have access) 
2. Enter your extended release note in the below block; leaving it blank means using the PR title as the release note. If no release note is required, just write `NONE`. 
-->

``` release-note
```

Previously, we had no way to stop resync goroutine when ListAndWatch
returned.  goroutine leaked every time ListAndWatch returned, for
example, with error.  This commit adds another channel to signal that
resync goroutine should exit when ListAndWatch returns.
2016-12-05 02:41:33 -08:00
Tatsuhiro Tsujikawa
991674380b Fix resync goroutine leak in ListAndWatch
Previously, we had no way to stop resync goroutine when ListAndWatch
returned.  goroutine leaked every time ListAndWatch returned, for
example, with error.  This commit adds another channel to signal that
resync goroutine should exit when ListAndWatch returns.
2016-12-02 15:26:25 +09:00
Nicolae Vartolomei
c6733f1c9e Handle cache/reflector errors when updating objects in store 2016-12-01 21:09:28 +02:00
Chao Xu
98a82de6d1 dependencies: pkg/client 2016-11-23 15:53:09 -08:00
Joe Beda
e0c6bf13b1
TODOs around stopping informers 2016-11-04 09:28:11 -07:00
Joe Beda
453bb17c3c
Remove constants that are no longer referenced 2016-11-04 09:28:11 -07:00
Chao Xu
2044927034 move watch.ListWatchUntil to its own package to avoid future import cycle 2016-10-30 13:14:20 -07:00
Michail Kargakis
78dfe52afb cache: remove obsolete internal package name 2016-09-28 11:35:48 +02:00
Wojciech Tyczynski
1c9e623045 Remove dead variable from reflector 2016-08-11 08:32:37 +02:00
joe2far
5ead89b5bb Fixed several typos 2016-07-13 15:06:24 +01:00
David McMahon
ef0c9f0c5b Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
Xiang Li
abbbd7c2f2 cache: reflector should never stop watching
A recent change tries to separate resync and relist. The motivation
was to avoid triggering relist when a resync is required.

However, the change is not effective since it stops the watcher. As hongchao
mentioned in the original comment, today's storage interface will not deliever
any progress notification to the watch chan. So any watcher that does not receive
events for the last few seconds will not be able to catch up from the previous
index after a hard close since the index of the last received event is out of
the cache window inside etcd2.

This pull request tries to fix this issue by not stoping watcher when a resync is
required.
2016-05-22 18:04:20 -07:00
Robert Rati
e388c137bb Separate sync and list functionality in the reflector. #23394 2016-05-19 07:41:24 -04:00
Chao Xu
c73406bcfe the garbage collector controller 2016-05-15 16:04:19 -07:00
Matt Freeman
89e5e81bea Handle possible error in client reflector run loops 2016-05-04 05:01:54 +00:00
Clayton Coleman
206308ea14 Provide better log output and name for reflectors
Reflectors started from goroutines are broken because Go doesn't allow
runtime.Callers to see the spawning goroutine. Do a best effort parse of
the call stack for now.

Add logging so that we can easily see which reflectors processes launch,
and measure in logs the frequency of sync intervals.
2016-03-24 17:37:31 -04:00
laushinka
7ef585be22 Spelling fixes inspired by github.com/client9/misspell 2016-02-18 06:58:05 +07:00
Jan Chaloupka
4389b3f0d6 Rewritte util.* -> wait.* wherever reasonable 2016-02-07 12:02:20 +01:00
harry
1032067ff9 Replace runtime reference by pkg 2016-02-01 21:06:44 +08:00
Hongchao Deng
9a10e95f6e docs: Reflector ListAndWatch 2016-01-15 18:19:19 -08:00
Clayton Coleman
8f203a28f1 Change runtime.Object signature 2015-12-15 13:36:25 -05:00
k8s-merge-robot
06df5c97e7 Merge pull request #18499 from wojtek-t/fix_reflector_race
Auto commit by PR queue bot
2015-12-15 01:19:06 -08:00
Wojciech Tyczynski
960808bf08 Switch to versioned ListOptions in client. 2015-12-14 14:26:09 +01:00
Wojciech Tyczynski
6a7e8861c2 Fix data-race in reflector test in Go 1.5.1 2015-12-14 09:47:45 +01:00
Wojciech Tyczynski
0cefb43707 Enable listing from memory 2015-12-09 16:24:14 +01:00
Wojciech Tyczynski
b0fcb5adef Pass ListOptions to List in ListWatch. 2015-12-07 11:53:53 +01:00
Wojciech Tyczynski
b6ef62af24 Use unversioned.ListOptions in clients. 2015-11-24 16:52:09 +01:00
feihujiang
ad79fa6e84 Move list functions from runtime to meta package 2015-11-20 09:20:55 +08:00
Wojciech Tyczynski
d47e21f19f Reuse TCP connections in Reflector between resync periods. 2015-10-26 19:35:25 +01:00
Daniel Smith
15b30b8b09 Move version agnostic parts of client
pkg/client/unversioned/cache -> pkg/client/cache
pkg/client/unversioned/record -> pkg/client/record
2015-09-10 17:17:59 -07:00
Kris Rousey
7ba5b058cc Moving client libs to unversioned dir 2015-08-18 10:03:19 -07:00
Wojciech Tyczynski
e424da7d0d Implement Cacher for watch in apiserver 2015-08-14 09:44:42 +02:00
Wojciech Tyczynski
52e3af4e93 Implement watchCache structure. 2015-08-07 08:29:17 +02:00
Mike Danese
17defc7383 run gofmt on everything we touched 2015-08-05 17:52:56 -07:00
Mike Danese
8e33cbfa28 rewrite go imports 2015-08-05 17:30:03 -07:00
Chao Xu
3b11705a99 downgrade errors returned by watchHandler in reflector.go to warnnings 2015-07-29 10:32:48 -07:00
deads2k
f203b16cd9 add originator to reflector logging 2015-07-10 11:34:49 -04:00
Filip Grzadkowski
7cdfb2ac7f Reduce number of list requests in watch-based cache 2015-06-03 00:55:49 +02:00
Jordan Liggitt
49ceb82179 Wait until stores are filled before processing service account token events 2015-05-20 22:19:42 -04:00
Daniel Smith
16a6fb8ef7 Replace calls to time.After with time.NewTimer for explicit stopping 2015-05-04 14:29:33 -07:00
Eric Paris
6b3a6e6b98 Make copyright ownership statement generic
Instead of saying "Google Inc." (which is not always correct) say "The
Kubernetes Authors", which is generic.
2015-05-01 17:49:56 -04:00
Prashanth Balasubramanian
5234c2dc82 Fix RunUntil and stop leaking watch channel on etcd error 2015-04-09 11:03:30 -07:00
derekwaynecarr
9df41301f0 Expose last sync resource version 2015-04-08 17:09:06 -04:00
derekwaynecarr
2ed8eed004 Make admission control plug-ins work from indexes 2015-03-06 09:36:57 -05:00
Daniel Smith
554b1c847c add occasional polling to reflector 2015-02-27 16:59:14 -08:00
Dan Mace
5ee943d683 Support namespacing in cache.Store implementations
Support namespacing in cache.Store by framing the interface functions
around interface{} and providing a key function to each Store implementation.

Implementation of a fix for #2294.
2015-01-29 17:39:49 -05:00
Clayton Coleman
f2d966859d Add RunUntil to the Reflector and Poller to allow early termination
This is useful for test suites where you want to kill your workers
without having to run one test env per execution.
2015-01-21 18:25:54 -05:00
Clayton Coleman
b2434de777 When connections are broken on Watch, write fewer errors to logs
Watch depends on long running connections, which intervening proxies
may break without the control of the remote server. Specific errors
handled are io.EOF, io.EOF wrapped by *url.Error, http connection
reset errors (caused by race conditions in golang http code), and
connection reset by peer (simply tolerated).
2014-12-18 16:15:51 -05:00
Dan Mace
0ad8342a55 Log ErrUnexpectedEOF from watches as warnings
Watches are often established via long-running HTTP GET requests which
will inevitably time out during the normal course of operations. When
the watches time out, an io.EOF or an io.ErrUnexpectedEOF will bubble
up to client components such as StreamWatcher and Reflector. Treat EOF
as a clean watch termination. Treat ErrUnexpectedEOF as a less-clean
but non-fatal watch termination and log the event at the warning level.

This greatly reduces the amount of log noise generated during what is
ultimately normal operation, and adds the flexibility for the operator
to make a distinction between the EOF conditions if so desired (by
adjusting the logging level).
2014-12-05 15:03:07 -05:00
Clayton Coleman
3df1c2f29d Use meta.Interface and meta.Accessor 2014-10-23 18:01:25 -04:00