Commit Graph

46 Commits

Author SHA1 Message Date
David Eads
f2d9cfb8c8 switch to using the real FIFO
Kubernetes-commit: a9aab298b4738f4ea9111131cdf193a3b1ba14e5
2025-01-10 16:23:23 -05:00
David Eads
d853ccf18c Remove Queue.AddIfNotPresent
Logically a cache.Queue.AddIfNotPresent means that the informer can move
back in time since an older item is placed after newer items.  The
alternative of placing errors at the head of the queue leads to
indefinite memory growth and repeated failures on retry.

Luckily this behavior was behind RetryOnError, which was always set to
false and impossible for normal users to set to true.  By removing the
function and setting, impacted users (none found in a github search)
will get a compile failure.

Kubernetes-commit: 8e77ac000131019d5aa49c19aa1f477f6dac4d59
2025-01-20 13:54:32 -05:00
Patrick Ohly
5d289bc44c client-go/tools/cache: add APIs with context parameter
The context is used for cancellation and to support contextual logging.

In most cases, alternative *WithContext APIs get added, except for
NewIntegerResourceVersionMutationCache where code searches indicate that the
API is not used downstream.

An API break around SharedInformer couldn't be avoided because the
alternative (keeping the interface unchanged and adding a second one with
the new method) would have been worse. controller-runtime needs to be updated
because it implements that interface in a test package. Downstream consumers of
controller-runtime will work unless they use those test package.

Converting Kubernetes to use the other new alternatives will follow. In the
meantime, usage of the new alternatives cannot be enforced via logcheck
yet (see https://github.com/kubernetes/kubernetes/issues/126379 for the
process).

Passing context through and checking it for cancellation is tricky for event
handlers. A better approach is to map the context cancellation to the normal
removal of an event handler via a helper goroutine. Thanks to the new
HandleErrorWithLogr and HandleCrashWithLogr, remembering the logger is
sufficient for handling problems at runtime.

Kubernetes-commit: 4638ba971661497b147906b8977ae206c9dd6e44
2024-07-26 15:26:00 +02:00
Wojciech Tyczyński
b9e952f4d7 Allow for configuring MinWatchTimeout in Reflector and Informer.
Kubernetes-commit: 29e38c19b853b6cc3950541b1727395acf5eb4d3
2024-04-09 09:12:54 +02:00
Wojciech Tyczyński
7da319745b Refactor informer constructors
Kubernetes-commit: 4da185a601e1f657a873dfd7e51efcc8a3b94c37
2024-04-09 09:06:38 +02:00
Mike Spreitzer
61be9f118e Add DeletionHandlingObjectToName
Signed-off-by: Mike Spreitzer <mspreitz@us.ibm.com>

Kubernetes-commit: d60a25b2db52d7e180b0962e23cc06e71f36fb29
2024-01-26 13:28:06 -05:00
kkkkun
3195e36899 Should get ENABLE_CLIENT_GO_WATCH_LIST_ALPHA when new reflector
Signed-off-by: kkkkun <scuzk373x@gmail.com>

Kubernetes-commit: 2eed9b4143a9009b3327003ae50dbbebb44d2841
2023-05-24 21:09:53 +08:00
Daniel Smith
c3b84f0438 Change where transformers are called.
Kubernetes-commit: e76dff38cf74c3c8ad9ed4d3bc6e3641d9b64565
2023-03-14 23:05:20 +00:00
Lukasz Szaszkiewicz
262b98af03 cache/controller: Add ENABLE_CLIENT_GO_WATCH_LIST_ALPHA
Kubernetes-commit: 966b26d55c22f7fbf20841a3a993de4f984d88db
2023-03-07 12:34:11 +01:00
Clayton Coleman
08e22c4b64 cache: Reflector should have the same injected clock as its informer
While refactoring the backoff manager to simplify and unify the code
in wait a race condition was encountered in
TestSharedInformerWatchDisruption. The new implementation failed
because the fake clock was not propagated to the backoff managers
when the reflector was used in a controller. After ensuring the
mangaers, reflector, controller, and informer shared the same
clock the test needed was updated to avoid the race condition by
advancing the fake clock and adding real sleeps to wait for
asynchronous propagation of the various goroutines in the controller.

Due to the deep structure of informers it is difficult to inject
hooks to avoid having to perform sleeps. At a minimum the FakeClock
interface should allow a caller to determine the number of waiting
timers (to avoid the first sleep).

Kubernetes-commit: 91b3a81fbd916713afe215f7d701950e13a02869
2023-01-14 14:17:33 -05:00
Daniel Smith
5d70a118df Enable propagration of HasSynced
* Add tracker types and tests
* Modify ResourceEventHandler interface's OnAdd member
* Add additional ResourceEventHandlerDetailedFuncs struct
* Fix SharedInformer to let users track HasSynced for their handlers
* Fix in-tree controllers which weren't computing HasSynced correctly
* Deprecate the cache.Pop function

Kubernetes-commit: 8100efc7b3122ad119ee8fa4bbbedef3b90f2e0d
2022-11-18 00:12:50 +00:00
Andy Goldstein
37897aff8d Reflector: support logging Unstructured type
Add an annotation that can be added to the exampleType passed to
NewReflector to indicate the expected type for the Reflector. This is
useful for types such as unstuctured.Unstructured, which, when used with
a dynamic informer, do not have their TypeMeta filled in.

Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com>

Kubernetes-commit: 474fc8c5234000bce666a6b02f7ffbb295ef135f
2022-08-17 15:49:26 -04:00
Davanum Srinivas
2a6c116e40 Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: a9593d634c6a053848413e600dadbf974627515f
2022-07-19 20:54:13 -04:00
Alexander Zielenski
54928eef9f modify SharedIndexInformer to use newInformer constructor which supports transformers
avoids code duplication, allows transformer to be used with SharedIndexInformer

Kubernetes-commit: 754bf3b3d02c66d1dd030460b03dddd3d6c7196d
2022-01-19 11:40:42 -08:00
wq
3480737c9e fix typos in comment
Kubernetes-commit: 3e2932179084fa322ba1bc53997d44e1d383db00
2022-01-08 23:39:23 +09:00
wojtekt
c702a411d1 Create TransformingIndexerInformer
Kubernetes-commit: 56ffb4e2b056622210bbf5ce845cf63ca18e85ce
2021-09-23 09:09:59 +02:00
wojtekt
b100ecfc06 Create TransformingInformer
TransformingInfomer is like a regular Informer, but allows for applying
custom transform functions on the objects received via list/watch API calls.

Kubernetes-commit: efd3490076c391823095b4c8bd6e847ae18eb012
2020-09-29 15:06:33 +02:00
wojtekt
01243dd50e Migrate to k8s.io/utils/clock in client-go
Kubernetes-commit: bb7dac443a2039f97c822f610e78d4b65482c56d
2021-09-17 11:36:09 +02:00
kfu
6db26dd413 Fixes formatting and typos in client-go docs
Kubernetes-commit: d0de4483d51c5811202f1731a835c75d8fc8b30e
2021-04-27 21:28:23 +02:00
Maciej Borsz
a52faa7892 Add WatchListPageSize to cache.Config
Currently there is no way to specify WatchListPageSize used by Controller. This PR adds a field that can be used to specify this.

Change-Id: I241454a45dd94d3ea65a91b297f530e217f843aa

Kubernetes-commit: 43f5afe1a1dd058a2564cd3b2f330fc2a401f607
2020-08-31 12:52:45 +02:00
gobomb
330cb14339 let panics propagate up when processLoop panic
Kubernetes-commit: 19a3ca2c289b6f3dc8cd495e3db0d347b5a3b774
2020-08-03 09:30:39 +00:00
Nick Santos
ccd5becdff cache: add error handling to informers
When creating an informer, this adds a way to add custom error handling, so that
Kubernetes tooling can properly surface the errors to the end user.

Fixes https://github.com/kubernetes/client-go/issues/155

Kubernetes-commit: 435b40aa1e5c0ae44e0aeb9aa6dbde79838b3390
2020-01-17 12:46:08 -05:00
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
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
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
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
Ted Yu
541253da74 Utilize reflectorMutex in LastSyncResourceVersion
Kubernetes-commit: 4f54538ae8ff7a4e6829bea1479194af87b7833c
2019-08-26 07:46:26 -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
Adrián Orive
0f2b134a3e Add newInformer documentation
Signed-off-by: Adrián Orive <adrian.orive.oneca@gmail.com>

Kubernetes-commit: b09c1ce5ddb7473b8b9dd5d63b46267381ed852f
2018-11-14 08:36:38 +01:00
Adrián Orive
2e9f26a34c Remove duplicate code
Signed-off-by: Adrián Orive <adrian.orive.oneca@gmail.com>

Kubernetes-commit: b6c3129ac5895db6df61601cfc72e2efa03fd72c
2018-11-08 15:46:56 +01:00
wojtekt
58ae7b3039 Couple fixes to DeltaFIFO machinery
Kubernetes-commit: d880f8c1ca3077496ceafadbb8807618b3f6e684
2019-01-23 09:45:37 +01:00
Dan Williams
577c46c713 Remove unused DeltaFIFO compressor argument to NewDeltaFIFO
Nobody uses it; the one or two older users from 1.4/1.5 timeframe
were removed for 1.6.  It's also poorly understood and the sole
example is in the testcases, and it's pretty incomplete.

If anyone really wants compression, they can revert this PR.

Kubernetes-commit: a56c8f50cb9b9bfdb92bc5f005a48f8df5afadb9
2017-03-21 14:53:30 -05:00
Mikhail Mazurskiy
1a0ee4cda2 Refactor Start functions into an object
Kubernetes-commit: 6464774a9b94f6e8376e11d015fd55e98457e74c
2017-07-19 03:39:07 +00:00
Mikhail Mazurskiy
0a8adc4df4 Improve Start functions
Kubernetes-commit: d11a9973cfd421b7f723156bbb2b256851f7460d
2017-07-19 03:39:07 +00:00
Mikhail Mazurskiy
5f6ea627a3 Shared Informer Run blocks until all goroutines finish
Fixes #45454

Kubernetes-commit: d789615902ead2a112ad24fbfebe95285b87004b
2017-07-19 03:39:07 +00:00
Clayton Coleman
d84ceacdd1 Add a filtering resource handler for informers
Allows an informer consumer to easily filter a set of changes out,
possibly to maintain a smaller cache or to only operate on a known set
of objects.

Kubernetes-commit: 5439cfd24571a1727aacf741d3ab8bd33f974cab
2017-05-21 17:20:29 +00:00
Clayton Coleman
09165439d7 Refactor move of client-go/util/clock to apimachinery
Kubernetes-commit: 3e095d12b4f152a45b593927804e2e7b8816239a
2017-05-21 17:20:29 +00:00
Guangya Liu
5a21aa58a2 Added indexer description for the API of NewIndexerInformer.
Kubernetes-commit: e42f7c7480c304144b3c90089232c5fc59229cce
2017-05-12 17:21:59 +00:00
Chao Xu
088dc4a30d manually sync with k8s.io/kubernetest at 17375fc59fff39135af63bd1750bb07c36ef873b, k8s.io/apimachinery at d90aa2c8531f13b0ca734845934c10dcb6a56ca7 2017-02-23 12:27:32 -08:00
Kubernetes Publisher
0e140df9af published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 3aa29bca4f6f9e43d8e2a8e3a1587d92b1b2dfe2
2017-01-17 15:19:43 +00:00
Kubernetes Publisher
204f12b1f3 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 616038db1b0d1e852b4a3d10c8c512a052f91fba
2017-01-14 15:19:47 +00:00
Kubernetes Publisher
89c6009983 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 800ef09dc19c04789c49c2e83e963bbd986cda7a
2016-11-12 03:39:06 +00:00
Kubernetes Publisher
75399f68c8 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is e56cfc5322138aa23e6418ee30a6ab54c7c6fe8c
2016-10-21 04:44:19 +00:00
Chao Xu
a6d206121d remove the top-level folders for versions
remove scripts
2016-10-19 14:34:19 -07:00