Commit Graph

24 Commits

Author SHA1 Message Date
Lukasz Szaszkiewicz
b42d55bc18 client-go/metadata: use watchlist
Kubernetes-commit: 0912e400cda2dd6ef6950dea15b18f826777ac41
2024-09-16 12:00:11 +02:00
Lukasz Szaszkiewicz
892e9b89df client-go/metadata: add watchlist method
Kubernetes-commit: 3a0aa1093f5e11afb3d729e5799c2de526c20de9
2024-09-16 11:56:54 +02:00
Lukasz Szaszkiewicz
68a23b85b6 client-go/metadata: refactor List method
Kubernetes-commit: 1994540ffc5495bc78a4aaa428873d04d4dda442
2024-09-16 11:51:26 +02:00
Ricardo Lopes
12b0e099db Migrate client-go/metadata to contextual logging (#122225)
* client-go: migrate metadata to contextual logging

Signed-off-by: Ricardo Lopes <ricardoapl.dev@gmail.com>

* client-go: test for metadata contextual logs

Signed-off-by: Ricardo Lopes <ricardoapl.dev@gmail.com>

* refactor: extract context for table driven testing

Signed-off-by: Ricardo Lopes <ricardoapl.dev@gmail.com>

* refactor: pass context as first parameter

Signed-off-by: Ricardo Lopes <ricardoapl.dev@gmail.com>

---------

Signed-off-by: Ricardo Lopes <ricardoapl.dev@gmail.com>

Kubernetes-commit: 86ab185fa1e98e249fe3e380217099832fe22a4e
2023-12-14 06:26:45 +00:00
Eric Lin
da4a4e2e16 Add 'WithTransform' SharedInformerOption
Also add support for metadata informer factory to use SharedInformerOption

Signed-off-by: Eric Lin <exlin@google.com>

Kubernetes-commit: 9c4651bd0479b84f5e5913649207476717f3f13e
2023-06-04 12:26:58 +00:00
Tim Hockin
12553015e2 Replace uses of ObjectReflectDiff with cmp.Diff
ObjectReflectDiff is already a shim over cmp.Diff, so no actual output
or behavior changes

Kubernetes-commit: bc302fa4144d21a338683cd83701661f97be4aba
2023-03-23 11:34:03 -07:00
Tim Hockin
c4339eeca9 Replace uses of ObjectGoPrintDiff with cmp.Diff
ObjectGoPrintDiff is already a shim over cmp.Diff, so no actual output
or behavior changes

Kubernetes-commit: 9627c50ef37f3b5274486e6f5ad37b73b1b69bf0
2023-03-23 11:31:25 -07:00
Tim Hockin
7114041b4f Replace uses of diff.ObjectDiff with cmp.Diff
ObjectDiff is already a shim over cmp.Diff, so no actual output or
behavior changes

Kubernetes-commit: 29c0b73d640b6e50c4f2dfeee7b07ca66a530dbd
2023-03-23 11:29:01 -07:00
John Howard
089d04441d client-go: support Shutdown() for metadata and dynamic informers (#114434)
* client-go: support `Shutdown()` for metadata and dynamic informers

Followup to https://github.com/kubernetes/kubernetes/pull/112200,
specifically
https://github.com/kubernetes/kubernetes/pull/112200#issuecomment-1344812038.

* add comments

* Defer lock

Kubernetes-commit: b99fe0d5b9896dd3fe9a2c1bc3b399a18ad080d2
2023-02-28 23:09:17 -08:00
inosato
27de641f75 Remove ioutil from client-go
Signed-off-by: inosato <si17_21@yahoo.co.jp>

Kubernetes-commit: 88dfa51b6003c90e8f0a0508939a1d79950a40df
2022-07-30 20:54:41 +09:00
jlsong01
470c93d04c allocate a unique scheme for each test to fix concurrent usage issue
Kubernetes-commit: d66b3edd65efba0760eb0a5668aac733f294903b
2022-01-31 15:23:42 +08:00
John Howard
f582d43dbd Make metadata fake client implement testing.FakeClient
This mirrors most (maybe all?) other fake clients. Example of a real
world use case this would have been useful:
https://github.com/istio/istio/pull/35434

Kubernetes-commit: 86c9fef160b37ce834b680e49cf237917d2e5c6c
2021-09-30 16:32:23 -07:00
Antonio Ojea
30025c3fbc expose NewForConfigAndClient for the metadata client
Kubernetes-commit: 909a1738fdf7b33513a1409860289a3d38d77267
2021-10-19 16:00:53 +02:00
scott
0c4682e956 explain the reason why metaclient special processing metav1.DeleteOptions encoding
metaclient explicitly specifies the Content-Type when executing Delete and DeleteCollection, and add test for that

Kubernetes-commit: 8976f6f6d9af22ad40df891565c19e4dfd67f591
2021-08-25 17:55:25 +08:00
Martin Schimandl
3450a048bc Fix staticchecks in vendor/k8s.io/client-go
Kubernetes-commit: 13c017056c924e148113e42786a511ed2fee7594
2020-10-01 12:40:32 +02:00
Davanum Srinivas
75fea27a27 switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
Quan Tian
faf5681d1c Improve fake clientset performance
The fake clientset used a slice to store each kind of objects, it's
quite slow to init the clientset with massive objects because it checked
existence of an object by traversing all objects before adding it, which
leads to O(n^2) time complexity. Also, the Create, Update, Get, Delete
methods needs to traverse all objects, which affects the time statistic
of code that calls them.

This patch changed to use a map to store each kind of objects, reduced
the time complexity of initializing clientset to O(n) and the Create,
Update, Get, Delete to O(1).

For example:
Before this patch, it took ~29s to init a clientset with 30000 Pods,
and 2~4ms to create and get an Pod.
After this patch, it took ~50ms to init a clientset with 30000 Pods,
and tens of µs to create and get an Pod.

Kubernetes-commit: 7e15e31e11e48a6db855e30ca9b07dbce3047577
2020-03-27 18:39:20 +08:00
Jordan Liggitt
5883a775b1 client-go metadata: plumb context
Kubernetes-commit: cb4ee9334b744404e670ea2c28a3093a3cd67844
2020-03-06 10:42:18 -05:00
Mike Danese
b136e9eb2b refactor
Kubernetes-commit: d55d6175f8e2cfdab0b79aac72046a652c2eb515
2020-01-27 18:19:44 -08:00
Clayton Coleman
9bbcc2938d Always negotiate a decoder using ClientNegotiator
This commit performs two refactors and fixes a bug.

Refactor 1 changes the signature of Request to take a RESTClient, which
removes the extra copy of everything on RESTClient from Request. A pair
of optional constructors are added for testing. The major functional
change is that Request no longer has the shim HTTPClient interface and
so some test cases change slightly because we are now going through
http.Client code paths instead of direct to our test stubs.

Refactor 2 changes the signature of RESTClient to take a
ClientContentConfig instead of ContentConfig - the primary difference
being that ClientContentConfig uses ClientNegotiator instead of
NegotiatedSerializer and the old Serializers type. We also collapse
some redundancies (like the rate limiter can be created outside the
constructor).

The bug fix is to negotiate the streaming content type on a Watch()
like we do for requests. We stop caching the decoder and simply
resolve it on the request. We also clean up the dynamic client
and remove the extra WatchSpecificVersions() method by providing
a properly wrapped dynamic client.

Kubernetes-commit: 3b780c64b89606f4e6b21f48fb9c305d5998b9e5
2019-11-10 16:52:08 -05:00
wojtekt
aebe267284 Ensure conversions are registered for metainternalversion codecs
Kubernetes-commit: 54163527a69a8c868b87d301876559495220d1b0
2019-09-11 16:30:08 +02:00
Clayton Coleman
0f7aa3096b Rename metadata.NewConfigOrDie to be consistent
Updated name to match dynamic client

Kubernetes-commit: 98d87a4f03e22bb8e4d22460855913d23930685a
2019-07-10 18:35:45 -04:00
Clayton Coleman
cade5c0473 Add fake client, informer factory, and lister to metadata client
These will be used by the garbage collector controller and others that
use higher level primitives.

Kubernetes-commit: bc89c37f32aa6cfd0f9ca975d9221d0a89320623
2019-06-05 14:28:51 -04:00
Clayton Coleman
0eaec69666 Add a metadata client to client-go that can read PartialObjectMetadata
This client exposes operations on generic metadata (get, list, watch, delete)
and allows patch operations. The client always uses protobuf and requests
the server transform the response into the appropriate object. Using this
client simplifies the work of generic controllers by allowing them to treat
all objects the same, and also improves performance both in the amount of
data sent as well as allowing protobuf on CRD resources.

Kubernetes-commit: 21f5e643d9dbe6b65d21713dc16ab8888de5423e
2019-04-02 15:45:07 -04:00