Commit Graph

176 Commits

Author SHA1 Message Date
Mike Spreitzer
d7a772a8de Documented mutation restriction for informer clients
Also brushed up some other informer comments for readability and
nitpicking accuracy.

Kubernetes-commit: c4774de94a80bb7d0f54a8a728ad3e97ad1a07b9
2020-03-16 17:38:14 -04:00
Mike Spreitzer
49f8c8f17a More refinement of comments and parameter names for informers
Removed the incorrect promise of coherency in the answer to a query to
an informer's local cache.  Removed the definition of "collection
state", because it was only used in the now-removed promise.  Added a
remark about ordering of states that appear in an informer's local
cache.

Brushed up the commentary on resync period.  Changed the relevant
parameter of NewSharedInformer to have the same name as the
corresponding parameter to NewSharedIndexInformer.

Kubernetes-commit: b8e2ad5926c3a6872422ad25cf9867e10e052a7d
2020-01-26 02:43:33 -05:00
Jordan Liggitt
b0779d525a Shrink mutation detection critical section
Kubernetes-commit: 12abf03f6b4a60fa61773acd21dfb440ff10f699
2020-02-13 22:22:14 -05:00
Harry Zhang
1df276a7c6 add exponential backoff with reset to reflector
Kubernetes-commit: f1248163ff4dc3cf164284bf255c10b6b538aa66
2020-02-03 15:32:51 -08:00
Jordan Liggitt
08cc53159f Treat replaced events that didn't change resourceVersion as resync events
Kubernetes-commit: a6caa0a4726ba97737056175494516367cf98cae
2020-02-08 16:30:01 -05:00
wojtekt
0e2dbbf70a Switch pager to return whether the result was paginated
Kubernetes-commit: 5dcf08c1993718e94cf6537af50e0a411dd2878c
2020-01-28 09:39:27 +01:00
wojtekt
5534e24283 Avoid thundering herd on etcd on masters upgrade
Kubernetes-commit: 773d3583bcb7a2ac39c772a9861978d81db0df2f
2019-12-30 13:53:28 +01:00
Mike Danese
b136e9eb2b refactor
Kubernetes-commit: d55d6175f8e2cfdab0b79aac72046a652c2eb515
2020-01-27 18:19:44 -08:00
Mike Spreitzer
cc22aafc1f remove unused layer of loop structure in processorListener::run
Also updated the comment inside processorListener::run, to restore
accuracy about how long the delay is.

Kubernetes-commit: d2ad469abbb1122cbbd772e15767817cd771f9f6
2020-01-20 11:52:44 -05:00
Casey Callendrello
b775e00fe5 informers: don't treat relist same as sync
Background:

Before this change, DeltaFIFO emits the Sync DeltaType on Resync() and
Replace(). Seperately, the SharedInformer will only pass that event
on to handlers that have a ResyncInterval and are due for Resync. This
can cause updates to be lost if an object changes as part of the Replace(),
as it may be incorrectly discarded if the handler does not want a Resync.

What this change does:

Creates a new DeltaType, Replaced, which is emitted by DeltaFIFO on
Replace(). For backwards compatability concerns, the old behavior of
always emitting Sync is preserved unless explicity overridden.

As a result, if an object changes (or is added) on Replace(), now all
SharedInformer handlers will get a correct Add() or Update()
notification.

One additional side-effect is that handlers which do not ever want
Resyncs will now see them for all objects that have not changed during
the Replace.

Kubernetes-commit: ca1eeb99b530a6d76b464dad545abc18d4508c49
2019-12-16 18:34:30 +01:00
Casey Callendrello
802190f49e client-go/cache/testing: add ability to simulate watch disruption
This adds ResetWatch() to the FakeControllerSource, which lets the
controller simulate a re-list-and-watch.

Kubernetes-commit: 5aacacbdf000cee2d0ec548ee4afe564f35c60bf
2019-12-06 22:19:42 +01:00
Mike Spreitzer
d01661091c Further tweaking up the wording
Hopfully improving, based on wojtek's review.

Kubernetes-commit: 59807be5abe6a96aad715823b7bab9fbd5d837bd
2020-01-10 16:05:41 -05:00
Mike Spreitzer
4aedce0891 gofmt reflector.go
Kubernetes-commit: 729337ec7e4251708b75f45ad40b7fa55ad14dd5
2020-01-07 08:56:31 -05:00
Mike Spreitzer
a1b3b98c4b Clarified comment on DeltaFIFO::Replace
Kubernetes-commit: ae53a008cb372f7301e302ee982269630e964b12
2020-01-07 02:40:01 -05:00
Mike Spreitzer
c68732b808 finished pass over comments on Controller, and commented sharedIndexInformer
Kubernetes-commit: f2a8e2d9c9cadc8a969efa1d4edef833ff701e2f
2020-01-07 02:23:29 -05:00
Mike Spreitzer
edca648925 A little more comment tweaking for cache.Controller
Kubernetes-commit: 7d82e23e6cd61af212e73f6fb77c2f74c1628a84
2020-01-06 16:11:26 -05:00
Mike Spreitzer
db5618cb1f began turning attention to cache.Controller
Kubernetes-commit: 72fa714d636dc2f614b251c78cd8297f7754b333
2020-01-06 15:59:11 -05:00
Mike Spreitzer
261b8a00e4 Reworded comment on requestedResyncPeriod
Tried to make it clearer.

Kubernetes-commit: 2ea338b63f2191d859ac68fbba74c93c1d7bc998
2020-01-06 13:10:39 -05:00
Mike Spreitzer
8454aaf1be Noted divergence between requestedResyncPeriod and resyncPeriod
Kubernetes-commit: eef49c965f471d575aef8de5f071ffc6fd31c44d
2020-01-06 01:56:52 -05:00
Mike Spreitzer
1f6e3b32af Started commenting processors
Kubernetes-commit: 5546d9f12f266a082805ad3a2293fe04e0029c78
2020-01-06 01:49:29 -05:00
Mike Spreitzer
2f9f325a3b Fix tests and improve comment on NewDeltaFIFO
Kubernetes-commit: 0eca8ae9cdbbbe0e5bf56f9931acdaa97cea91af
2020-01-03 01:01:05 -08:00
Mike Spreitzer
bad9a45b33 Fixed assignment statements
Kubernetes-commit: 1d65f1b5c3977362fb5a32b9cfe5b9930fabf16a
2020-01-03 00:47:19 -08:00
Mike Spreitzer
0421cde51b Revised comments about f.knownObjects and added tests for Replace
Kubernetes-commit: 89c615f9c448503b674a0d61bfa8e413cefa4104
2020-01-03 00:44:02 -08:00
Mike Spreitzer
c26559b124 Updated comments on internal abstractions in client-go/tools/cache
The comments on Store and Queue and the FIFOs ceased being accurate
long ago.

Kubernetes-commit: 7a7ccb797e0c977c8049c1490f5a1f92f0bfbbb2
2020-01-02 01:53:17 -08:00
matte21
7d44382a3c Reword modifications for clarity
Kubernetes-commit: 21f59c99232afeae05dcdb4f2d1d156cda6a8a77
2019-12-31 09:48:28 +01:00
matte21
ce6197e865 Fix error in periodic resyncs description
Make it clear that periodic resyncs fire update notifications, not
create notifications as the old comments incorrectly stated.

Kubernetes-commit: 3ae8c864de24a2ad42321c9cbd71099a2b6dcef3
2019-10-28 14:23:37 +01:00
matte21
85843e6e02 Clarify that OnUpdate can mask delete and recreate
Kubernetes-commit: ff543ddfc09adf3d0abdf42f9d9fbd57c3ab4b43
2019-10-28 14:12:22 +01:00
wojtekt
f229b70415 Don't paginate in listwatch
Kubernetes-commit: 51eb4b50a3a607ba15a215fdcaa50baea5777afb
2020-01-02 20:09:19 +01:00
danielqsj
f67770132d unify alias of api errors under pkg and staging
Kubernetes-commit: 5bc0e26c1902e7e28abfc828de19a2dbb3e492c2
2019-11-12 16:26:59 +08:00
Jordan Liggitt
f8772cd39b Retain objects for a limited lifetime in the mutation cache detector by default
Kubernetes-commit: 81d05e91b5b5e653e20cc6ab620de08abfd0cbc2
2019-11-15 13:59:58 -05:00
Mateusz Matejczyk
d7b4c23325 pager.go: Don't set ResourveVersion on subsequent List calls
Ref. https://github.com/kubernetes/kubernetes/issues/85221#issuecomment-553748143

Kubernetes-commit: 977ca43d640d2a85e199a8a282e2df8ebd88055a
2019-11-14 11:34:59 +01:00
Pete de Zwart
ab63be7642 - Delete backing string set from a threadSafeMap index when the string set length reaches 0.
- Added thread_safe_store_test exercising new index backing string set delete at 0 functionality.

- TestThreadSafeStoreDeleteRemovesEmptySetsFromIndex logic nesting inverted.

- Added test case for usage of an index where post element delete there is non-zero count of elements and expect the set to still exist.

- Fixed date.

- Fixed awprice nits.

- Fix bazel.

Kubernetes-commit: 29a051388a719e0359969b8431de8e38e955e2a6
2019-11-08 16:57:06 +11:00
Joe Betz
a3f022a93c Add HTTP 410 (Gone) status code checks to reflector and relist with RV=''
Kubernetes-commit: e2fe126d485af243d45f06bafd2ca83931881429
2019-10-09 16:45:32 -07:00
Joe Betz
54033229aa Handle expired errors with RV>0 in pager, don't full list if 1st page is expired
Kubernetes-commit: 1f3dc14eea231c90819cbba06f25cb4221236b3f
2019-10-04 17:08:22 -07:00
wojtekt
7d13a606b3 Avoid going back in time in reflector framework
Kubernetes-commit: b2b285a766540278a768dc9e6bd07a3a676ae543
2018-08-29 11:40:25 +02:00
sshukun
cd92d91e0f Fix typo in k8s.io/client-go/tools/cache/index.go
Kubernetes-commit: a0d3e6750ecbc67d017c2c67d0ff6f12e1b0c1f1
2019-10-21 13:30:45 +09:00
Bob Killen
dc265f33cf Prune inactive owners from staging/src/k8s.io/client-go/* OWNERS files.
Kubernetes-commit: 3dc01f32eacb4791b248c22f7db9d6dabbec7869
2019-10-12 19:44:19 -04:00
matte21
cc50c9b333 Remove check causing informers to miss notifications
Fix DeltaFIFO bug that caused the sync delta created by a relist
for object ID X to be dropped if the DeltaFIFO already stored a
Delete delta for X. This caused SharedIndexInformer to miss create
notifications. Also, add unit test to expose the bug.

Kubernetes-commit: 9e4be54895e8c0655408b4766cd78de17b6d5b7c
2019-10-14 18:19:05 +02:00
Maru Newby
ab4e4fccf4 Add support for type checking Unstructured via GVK in reflector
It was previously possible to instantiate `Reflector` with
`*unstructured.Unstructured` as the expected type but this did not
support checking that event objects were of the correct API
type (e.g. if event object was `v1.Pod` in `Unstructured` form but
`v1.Service` was expected). This commit adds support for providing a
GVK via an `Unstructured` expected type to compare with the GVK of
event objects. The GVK will also be used in reflector log output.

Kubernetes-commit: 237dbfd8ad322dfcad4bd4d5345368480c22d82f
2019-09-24 01:20:40 +00:00
RainbowMango
e990876d88 Cleanup staticcheck from staging/src/k8s.io/client-go/tools/cache.
Kubernetes-commit: 19e5c8565d444cbb81d554a69960d7144996b05a
2019-09-04 18:32:06 +08:00
Darren Shepherd
6d3b14b468 Check cache is synced first before sleeping
If a cache was already synced, cache.WaitForCacheSync would
always take 100ms to complete because the PollUntil method will
sleep first before checking the condition.  Switching to
PollImmediateUntil will ensure already synced caches will return
immediately.  For code that has, for example, 20 informers, the time
to check the cache was in sync would take at least 2 seconds, but with
this change it can be as fast as you can actually load the data.

Signed-off-by: Darren Shepherd <darren@rancher.com>

Kubernetes-commit: 8a58f332dd62b68ae22c67585002defe6aeb4b04
2019-09-06 16:30:04 -07:00
Yassine TIJANI
7ee6383729 move WaitForCacheSync to the sharedInformer package
Signed-off-by: Yassine TIJANI <ytijani@vmware.com>

Kubernetes-commit: 7e4c3096fe71afc6a23c273b3309ed5db7289d8c
2019-08-16 21:15:53 +02:00
Ted Yu
541253da74 Utilize reflectorMutex in LastSyncResourceVersion
Kubernetes-commit: 4f54538ae8ff7a4e6829bea1479194af87b7833c
2019-08-26 07:46:26 -07:00
likakuli
6a1fb71239 fixes a bug that connection refused error cannot be recognized correctly
Kubernetes-commit: 3cec9098020ecc168573c7ee658282954dac2a2e
2019-08-20 12:18:46 +08:00
Mike Spreitzer
0c0e2ef3a2 Added info requested in review of #77636, and more
Added definition of "collection states" and noted that informer cache
queries are answered against these.

Also added an explicit note that the concept of object identity used
in the contract here does _not_ include ObjectMeta.UID.

Also updated the description of the notifications received by a
client, to account for the fact that a client can be added after the
informer starts running.

Added references to `MetaNamespaceKeyFunc` and
`SplitMetaNamespaceKey`.

Noted that a client must process each notification promptly and added
a referral to workqueue.

Made a couple other minor clarifications and corrections.

Kubernetes-commit: 848301e11a8558f6a90e2fada870a91baace812a
2019-07-25 01:45:22 -04:00
Joe Betz
1522bb2fc6 Replace string concatination with trace fields
Kubernetes-commit: 46a04d50af78e01d06a9879d62cc71fbe892076f
2019-08-02 23:47:24 -07:00
Ted Yu
a865205fb0 Store key in TimestampedEntry
Kubernetes-commit: 69fb4e960f7359641b3503b734acc32af6b05e04
2019-07-29 14:53:49 -07:00
RainbowMango
2b8d87c082 1. Fix lint errors for the whole directory staging/src/k8s.io/client-go/tools/cache;
2. Remove staging/src/k8s.io/client-go/tools/cache from .golint_failures;
3. Fix some typo from comments.

Kubernetes-commit: 0e0e1f7daba0a6ae6dd59df0a1bb643c323ad8cb
2019-07-10 12:00:52 +08:00
wojtekt
a553c2c2cc Enable watch bookmarks in reflector
Kubernetes-commit: 175c07f4e6d3a59bb6d9870c4a4a78c41940b2dd
2019-07-04 13:12:08 +02:00
Odin Ugedal
2ee65257e5 Fix file permissions for non executable files
Normal files should have permissions 644 by default,
and does not require the last bit to be
executable

Signed-off-by: Odin Ugedal <odin@ugedal.com>

Kubernetes-commit: 35cb87f9cf71776e99a970dfff751cd29ba7ebfb
2019-06-14 21:04:39 +02:00