Commit Graph

299 Commits

Author SHA1 Message Date
Uwe Krueger
d73e40f207 rename handle to registration
Kubernetes-commit: 7054ac16d43a4a55d6e7b69943eb209f6495c4ce
2021-08-04 21:54:32 +02:00
Alexander Zielenski
b3a61c6731 remove informational informer methods again
Kubernetes-commit: f52f4a8e3045fd3eeba0315a347ed653012cd5c5
2022-06-16 00:09:20 -07:00
Alexander Zielenski
ecdc8bf729 support removal of event handlers from SharedIndexInformers
To be able to implement controllers that are dynamically deciding
on which resources to watch, it is required to get rid of
dedicated watches and event handlers again. This requires the
possibility to remove event handlers from SharedIndexInformers again.
Stopping an informer is not sufficient, because there might
be multiple controllers in a controller manager that independently
decide which resources to watch.

Unfortunately the ResourceEventHandler interface encourages to use
value objects for handlers (like the ResourceEventHandlerFuncs
struct, that uses value receivers to implement the interface).
Go does not support comparison of function pointers and therefore
the comparison of such structs is not possible, also. To be able
to remove all kinds of handlers and to solve the problem of
multi-registrations of handlers a registration handle is introduced.
It is returned when adding a handler and can later be used to remove
the registration again. This handle directly stores the created
listener to simplify the deletion.

Kubernetes-commit: 7436af3302088c979b431856c432b95dd230f847
2022-06-16 00:07:54 -07:00
Marcel Zięba
ff6bf679aa Add option to retry internal api error in reflector.
Kubernetes-commit: 0b2b6489de8f75d5299f54180617601126bb8878
2022-07-25 08:02:54 +00: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
Lukasz Szaszkiewicz
441e2c8c97 reflector: simplify reading the resourceVersion
Kubernetes-commit: 63b125d4061d267ad8998ea30e054bb1445b1a5a
2022-07-15 10:14:26 +02:00
Lukasz Szaszkiewicz
04f67d5d4f reflector: move LIST to its own method
Kubernetes-commit: 6fc09008def0b63fdd31bd26a14f7fcd3ed63c7e
2022-06-24 16:25:08 +02:00
Lukasz Szaszkiewicz
4e28921c86 reflector: refactor watchHandler
Kubernetes-commit: e9e26068b746315b616a26b91ff2613f98e934bc
2022-06-24 13:44:32 +02:00
weilaaa
64585cf823 correct input params and add godoc
Kubernetes-commit: 9847b2eeb43e3fd13581dfdb4eeb288139ea7f3b
2022-06-22 11:26:07 +08:00
Karl Isenberg
876406445a fix: reflector to return wrapped list errors
This fix allows Reflector/Informer callers to detect API errors using the standard Go errors.As unwrapping methods used by the apimachinery helper methods. Combined with a custom WatchErrorHandler, this can be used to stop an informer that encounters specific errors, like resource not found or forbidden.

Kubernetes-commit: 9ace604b63045ebbb066cab5e8508b51d0900a05
2022-05-16 16:33:30 -07:00
Andrew Stoycos
f19a514ff5 Fix Panic Condition
Currenlty an event recorder can send an event to a
broadcaster that is already stopped, resulting
in a panic.  This ensures the broadcaster holds
a lock while it is shutting down and then forces
any senders to drop queued events following
broadcaster shutdown.

It also updates the Action, ActionOrDrop,  Watch,
and WatchWithPrefix functions to return an error
in the case where data is sent on the closed bradcaster
channel rather than panicing.

Lastly it updates unit tests to ensure the fix works correctly

fixes: https://github.com/kubernetes/kubernetes/issues/108518

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>

Kubernetes-commit: 6aa779f4ed3d3acdad2f2bf17fb27e11e23aabe4
2022-02-11 14:50:19 -05:00
Michael Bolot
e540ebe994 Addresses the issue which caused #109115
Kubernetes-commit: cbbb5f70a47644f9830073d9d0329bf247a328a1
2022-03-29 12:35:13 -05:00
Wojciech Tyczyński
1cab68940f Add test for indexer with multiple values
Kubernetes-commit: 56159f258ca380600b0bc08b2e99cbc745db3560
2022-03-30 08:52:10 +02:00
Jian Li
6b59aa0b4a make comments of updateIndices optimization code more accurate
Kubernetes-commit: 0eae1f3addbd044793dac89f9e097e5f4c6fb2aa
2022-03-14 13:56:17 +08: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
Ismayil Mirzali
664b1a6c8c client-go: refactor: Fix styling issues (#107248)
* client-go: Remove unreachable return

Due to the way the switch statement is done,
the return at the end of the function will neverbe reached.

Signed-off-by: Ismayil Mirzali <ismayilmirzeli@gmail.com>

* client-go: Refactor for clarity

Fixed one instance where the error message should be lowercase.
Made the fields in the struct literal more explicit

Signed-off-by: Ismayil Mirzali <ismayilmirzeli@gmail.com>

Kubernetes-commit: 75c0987de3cb9a0380873745f68dea2f0835a7a2
2022-01-18 12:03:08 +02:00
Davanum Srinivas
3bf0eac274 OWNERS cleanup - Jan 2021 Week 1
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 9682b7248fb69733c2a0ee53618856e87b067f16
2022-01-03 10:59:47 -05:00
wq
3480737c9e fix typos in comment
Kubernetes-commit: 3e2932179084fa322ba1bc53997d44e1d383db00
2022-01-08 23:39:23 +09:00
astraw99
a8ff96d887 fix log typo
Kubernetes-commit: abce7ab534d0c667dd1438ff24bb3130d17d3f6e
2021-11-19 11:06:14 +08:00
Davanum Srinivas
73f2731e23 Cleanup OWNERS files (No Activity in the last year)
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 497e9c1971c9e7d0193bc6d11503ec4ad527f1d5
2021-12-10 15:18:50 -05:00
Davanum Srinivas
70f09c4943 Check in OWNERS modified by update-yamlfmt.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 9405e9b55ebcd461f161859a698b949ea3bde31d
2021-12-09 21:31:26 -05:00
hyschumi
547d6c809a refactor: remove dup code
Signed-off-by: hyschumi<msliudongsheng@gmail.com>

Kubernetes-commit: da5d0a72d9d2a0948e21b746a8c6951dc40c0ce9
2021-11-04 21:11:53 +08:00
Antoni Zawodny
9af7db3c25 Add more info to the ListAndWatch trace
Kubernetes-commit: 093aa210be67f45efb1005f273d8d68444156473
2021-10-21 14:33:57 +02:00
astraw99
1816a40bbb fix word comment to common
Kubernetes-commit: 3e31933471e015a860e1967acfe730bb35422f17
2021-08-29 19:06:04 +08: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
e61d0d5d52 Optimize index updating
Kubernetes-commit: 75273a0689250f4861ea41405e6402c6191563a8
2021-09-24 15:24:01 +02:00
wojtekt
463b3d12bb Optimize indexer
Kubernetes-commit: 27c94a49c80202790e195dde3a258cc62110c1e5
2021-09-24 14:46:56 +02:00
wojtekt
01243dd50e Migrate to k8s.io/utils/clock in client-go
Kubernetes-commit: bb7dac443a2039f97c822f610e78d4b65482c56d
2021-09-17 11:36:09 +02:00
kitianFresh
f0bcda0dce avoid sharedIndexInformer run more than once, avoid more cache and memory consume
Kubernetes-commit: 305c13faca48d1a6ea4d263e262ebc8df0387c84
2021-09-09 13:37:25 +08:00
Dingzhu Lurong
b86695770f Improve DeltaFIFO function 'ListKeys'
In function ListKeys, it better to use ‘queue’ instead of 'items' to get all the keys.

Kubernetes-commit: f0ce8755287b1cad087b61abfcccd79c9f151828
2021-09-02 14:02:54 +08:00
00255991
c209a2e2bc para 'resourceVersion' in DeltaFIFO.Replace is not used, so remove it
Kubernetes-commit: 2949045ec47163485118c25c40907eb43c090fac
2021-09-08 19:10:40 +08:00
astraw99
33e23edf09 fix sharedInformer doc
Kubernetes-commit: 9d84ffafd06e6ca455aa279bd513758696e8e875
2021-09-07 16:45:07 +08:00
astraw99
f100d86401 fix typo CRED to CRUD
Kubernetes-commit: f8b82e189cfdc3aca7b9d789cc6f3131897f0ebc
2021-08-22 21:19:30 +08:00
Antonio Ojea
c63d830a92 client-go: deltaFIFO trace slow handlers
If the informers handlers are slow processing the objects, the deltaFIFO
blocks the queue and the streamWatchers can not add new elements to the
queue, creating contention and causing different problems, like high
memory usage.
The problem is not easy to identify from a user perspective, typically
you can use pprof to identify a high memory usage on the StreamWatchers
or some handler consuming most of the cpu time, but users should not
have to profile the golang binary in order to know that.

Metrics were disabled on the reflector because of memory leaks, also
monitoring the queue depth can't give a good signal, since it never goes high

However, we can trace slow handlers and inform users about the problem.

Kubernetes-commit: d38c2df2c4b945bcf1f81714fc6bfd01bbd0f538
2021-07-26 16:00:31 +02:00
Patrick Ohly
67de95ce2f client-go: reduce log level of reflector again
https://github.com/kubernetes/kubernetes/pull/87795 most likely
unintentionally increased the log level of "Starting reflector" and
"Stopping reflector", with the result that since Kubernetes 1.21
clients have printed that message by default. This is undesirable, we
should use the original level 3 again.

Kubernetes-commit: fd972934e4916879b04508686302659ce82cfa75
2021-06-10 20:36:02 +02:00
刁浩 10284789
5b0c7191ef simplify returning boolean expression in staging/src/k8s.io/client-go/tools
Signed-off-by: 刁浩 10284789 <diao.hao@zte.com.cn>

Kubernetes-commit: 9173414da6d1c70436b256d6068e3737a7434f6a
2021-05-24 07:15:36 +00:00
kfu
6db26dd413 Fixes formatting and typos in client-go docs
Kubernetes-commit: d0de4483d51c5811202f1731a835c75d8fc8b30e
2021-04-27 21:28:23 +02:00
c00522440
ca138c86e8 Change time.Now().Sub(x) to time.Since(x) for cleanup
Kubernetes-commit: 878548ceac9c109881c379911b8b0d8fce5ea68e
2021-04-12 10:27:54 +08:00
scott
c7901fa3e4 modify the elements in the array directly without allocating a new array
Kubernetes-commit: 238fce9357634502badbcc3704b0655cf8c378c3
2021-01-12 19:58:21 +08:00
Iceber Gu
8269e41416 client-go/cache: fix the AddIfNotPresent method of the DeltaFIFO
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>

Kubernetes-commit: c75bd4a535123f5032f78ffb246ed62b79617b44
2021-04-01 13:44:16 +08:00
Iceber Gu
fc03592e80 client-go/cache: support errors.Unwrap for KeyError
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>

Kubernetes-commit: 85fa121f84ee33bdc8d77e7a35d1f4d2c063c28f
2021-04-02 10:17:57 +08:00
Monis Khan
7998e982ab Prune stale entries from OWNERS files
Signed-off-by: Monis Khan <mok@vmware.com>

Kubernetes-commit: 91241eac9b7a7e62cc31e663147294bf6dc8f875
2021-04-07 10:38:27 -04:00
wojtekt
03ebb2739b Handle 429 errors from watch requests in reflector library.
Kubernetes-commit: a9daa46d470e87ed328688bebd9314cc5ac0fc4a
2021-03-13 12:29:44 +01:00
Wang Yiping
aa707b1f81 Replace deprecated NewDeltaFIFO with NewDeltaFIFOWithOptions
Kubernetes-commit: 8dc45c8e0ecdefa37df8c118f38fa0767c5c52b0
2021-03-18 08:30:29 +08:00
Jordan Liggitt
21ee617309 Add test timeout to mutation detector test
Kubernetes-commit: 877d889ac2c78b1c8c94dc2839351aad4136f908
2021-03-06 18:16:42 -05:00
Jordan Liggitt
0693903770 Fix or remove tests that don't work in race mode
Kubernetes-commit: 68bb8b827b3827cbee61d3fcc560738beba3e110
2021-03-04 09:51:52 -05:00
Nikhita Raghunath
1d0cb03f5a *: remove nikhiljindal from OWNERS
Kubernetes-commit: 6cef3a4e33c10c27bb301a1070ea3ff4cdad0c39
2021-02-16 10:50:50 +05:30
Nikhita Raghunath
e8ab2528ca *: remove madhusudancs from reviewers
Kubernetes-commit: 6b12c96a9b7fe4d7c03d0dfed447edd6b1055067
2021-02-16 10:40:42 +05:30
Victor Timofei
53a09c71a4 Update the wording of the DeltaFIFO
Kubernetes-commit: 3a107951f0bf16a022b70a667c98833e4ac1d540
2020-12-24 16:33:04 +02:00