278 Commits

Author SHA1 Message Date
Mayuka Channankaiah
753cfe1811 client-go, kubectl: Replace deprecated ErrWaitTimeout with recommended method (#132718)
* client-go: Replace depracted ErrWaitTimeout with recommended method

* Fix UT and Integration tests

* IT test

Kubernetes-commit: ffe306d67958297202e9492ea644b42c0e7e694d
2025-07-24 20:26:27 +05:30
Šimon Lukašík
f4943db564 ci: remove unnecessary test harness
This TestMain() is equivalent to not having any TestMain() at all.

This is the only such instance in whole repo.

Kubernetes-commit: 7e5aafcb164db5135a4d18ee4661c8813f2cc908
2025-07-21 12:59:52 +02:00
Davanum Srinivas
f4d210639b Bump k8s.io/kube-openapi to latest SHA (f3f2b991d03b)
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: ebc1ccc491c944fa0633f147698e0dc02675051d
2025-07-10 09:21:52 -04:00
Nelo-T. Wallus
6116f46372 Update docs on shutdown and draining
Kubernetes-commit: 67aaa956da3e6110e8155cc08539c488fc5e1298
2025-07-09 21:43:30 +02:00
Mikhail Mazurskiy
76df3ebd2e Use sets.Set instead of a local impl
Kubernetes-commit: d193ffe57ffbbbc07dd49993e4f06ab3b50b2317
2025-07-07 19:21:39 +10:00
PatrickLaabs
286cc8368b chore: depr. pointer pkg replacement for the csr
Kubernetes-commit: 6c3146e3557e1de3d617f49d0b64ee380a42a8b1
2025-07-03 11:34:13 +02:00
Lukasz Szaszkiewicz
16465459fa client-go/util/consistencydetector: move IsDataConsistencyDetectionForWatchListEnabled
Kubernetes-commit: 32fcaf14067c3dc054c887f5060bdb3325965014
2025-06-17 15:05:46 +02:00
Lukasz Szaszkiewicz
a7dabba123 client-go/util/consistencydetector: remove CheckListFromCacheDataConsistencyIfRequested
Kubernetes-commit: bad49390493c10e5288ecdd5d81dc6c16f2b7520
2025-06-17 13:37:57 +02:00
Davanum Srinivas
f21dd69478 Add a replacement for cmp.Diff using json+go-difflib
Co-authored-by: Jordan Liggitt <jordan@liggitt.net>
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 03afe6471bdbf6462b7035fdaae5aa0dd9545396
2025-06-10 23:08:41 -04:00
Patrick Ohly
8f2e17a6ba client-go workqueue: clarify parallel reenqueuing
"Is allowed" does not exactly say what happens. Let's be more explicit.

Kubernetes-commit: 772d010665141cf74d4a34af6da08ea4761ce1f8
2025-05-19 08:02:43 +02:00
novahe
3262fdedea Certificate store: ensure data is written to disk
Kubernetes-commit: 653f48d8867d0b8487e3f824b3680ddc7d85758f
2025-03-30 10:46:59 +08:00
Patrick Ohly
a96aa53864 client-go workqueue: add optional logger
NewTypedDelayingQueueWithConfig spawns a goroutine, but apparently shutdown is
already handled somehow. Therefore only the option to set a logger gets added
to the Config struct.

The problem then becomes that developers might forget to set that
logger. logcheck can't detect that. For now, all in-tree users get updated
immediately.

Kubernetes-commit: f20eb2e7c16a9b28e69fd0bba2000e7166d68f29
2024-12-11 12:45:57 +01:00
Patrick Ohly
d0f5d55191 client-go certificate: context-aware APIs and logging
For NewManager, the Config struct gets changed (not extended!) so that the
caller can provide a logger instead of just a logging function. Breaking the
API was chosen because it avoids having to maintain two different log calls in
various places (one for printf-style logging, one for structured logging).

RequestCertificateWithContext is an extension. It enables getting rid of
context.TODO calls.

NewFileStoreWithLogger also is an extension.

Kubernetes-commit: f9051901cee8d8ff4aed3db27ff495a706f1a487
2024-12-09 12:45:54 +01:00
HirazawaUi
5c249861a4 adjusting loopback certificate validity in kube-apiserver
Kubernetes-commit: 553e9bf84d199be3d6a3da6675671859723219f4
2025-02-08 19:43:48 +08:00
Davanum Srinivas
de67e026ad Linter to ensure go-cmp/cmp is used ONLY in tests
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 4e05bc20db99ff89b2d2205218d24b9935a7fdd7
2025-01-24 17:03:29 -05:00
Antonio Ojea
92b4ec71fb flowcontrol: remove testing dependencies
The methods NewFakeClock were using a testing dependency as a parameter,
to avoid breaking compatibility and to remove this dependency, just use
the clock.Clock interface.

If we have to do it again most probable we have chosen other pattern and
for sure other names, but now is too late.

Kubernetes-commit: 5c283cbb453acac9869b49020f6f999796360729
2024-12-12 17:42:41 +00:00
Patrick Ohly
70a4950f35 remove import doc comments
The "// import <path>" comment has been superseded by Go modules.
We don't have to remove them, but doing so has some advantages:

- They are used inconsistently, which is confusing.
- We can then also remove the (currently broken) hack/update-vanity-imports.sh.
- Last but not least, it would be a first step towards avoiding the k8s.io domain.

This commit was generated with
   sed -i -e 's;^package \(.*\) // import.*;package \1;' $(git grep -l '^package.*// import' | grep -v 'vendor/')

Everything was included, except for
   package labels // import k8s.io/kubernetes/pkg/util/labels
because that package is marked as "read-only".

Kubernetes-commit: 8a908e0c0bd96a3455edf7e3b5f5af90564e65b0
2024-12-02 14:43:58 +01:00
Laura Lorenz
ab2cdceca1 Maintain 10 minute recovery threshold for container backoff
Signed-off-by: Laura Lorenz <lauralorenz@google.com>

Kubernetes-commit: a0b83a774102a6d8ce03ce03c9d0431b44559019
2024-10-26 02:17:23 +00:00
Ben Luddy
8cb21671f4 Add CBOR feature gates.
For alpha, there is one apiserver feature gate and two client-go feature gates controlling
CBOR. They were initially wired to separate test-only feature gate instances in order to prevent
them from being configurable at runtime via command-line flags or environment variables (for
client-go feature gates outside of Kubernetes components). All of the integration tests required by
the KEP as alpha criteria have been implemented. This adds the feature gates to the usual feature
gate instances and removes the temporary code to support separate test-only feature gate instances.

Kubernetes-commit: 072dfcb416fd4e1ddab0a89ac4faf519e268bc96
2024-11-04 10:40:19 -05:00
Ben Luddy
cff56219d9 Support application/apply-patch+cbor in patch requests.
Kubernetes-commit: 37ed906a33211c7d578cab2d681941ebfd2f2f23
2024-10-22 16:08:24 -04:00
Antonin Bas
3c28f81659 Use generics for waitFor (delaying workqueue) in client-go
With this change, we can typically avoid an extra heap allocation when
calling AddAfter with a positive duration (which causes the creation of
a waitFor object). This is because workqueues are typically used with
string keys, and casting a string (or more generally, non-pointer types)
to an `interface{}` will cause an heap escape / allocation.

Ater this change, there is no longer any usage of `type t interface{}`,
which was creating some confusion after the switch to generics in the
workqueue package.

Co-authored-by: Quan Tian <quan.tian@broadcom.com>
Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>

Kubernetes-commit: 53ddffb55709857fec6bddbd5ca4ca1b03f7da97
2024-10-08 15:12:11 -07:00
Antonin Bas
5b31113588 Use generics for workqueue metrics
The workqueue implementation was recently updated to be strongly typed,
using Go generics. However the metrics implementation was not updated,
and continued using interface{}. This translated to unnecessary memory
allocations when invoking the queueMetrics interface methods to track
queue operation. We can avoid these extra heap allocations by using
generics for the metrics implementation as well.

Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>

Kubernetes-commit: 1aec7568e111f5855121e3afacacf431e5f95948
2024-09-25 14:35:03 -07:00
Alvaro Aleman
71640ef872 Fix accidental breaking change in TypedNewDelayingQueue
It was added for compatibility reason but ended up getting a `config`
argument by accident, resulting in not actually being compatible, this
change fixes that.

Kubernetes-commit: 6933c1bc229c196e9c71061e19a0cdc76adb1dbc
2024-09-30 18:33:30 -04:00
Matthieu MOREL
9d7f486102 fix: enable expected-actual rule from testifylint in module k8s.io/client-go
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Kubernetes-commit: 8286a69034d58e1ceafd6a6e5590bfcebd920b5b
2024-09-27 07:48:55 +02:00
Lukasz Szaszkiewicz
5395fd1e28 adds watchListEndpointRestrictions for watchlist requests (#126996)
* endpoints/handlers/get: intro watchListEndpointRestrictions

* consistencydetector/list_data_consistency_detector: expose IsDataConsistencyDetectionForListEnabled

* e2e/watchlist: extract common function for adding unstructured secrets

* e2e/watchlist: new e2e scenarios for convering watchListEndpointRestrict

Kubernetes-commit: ae35048cb0b9b177891aab41346b6d6cc504582f
2024-09-25 12:26:22 +00:00
Alvaro Aleman
c311da2251 Rename TypedNewDelayingQueue to NewTypedDelayingQueue
This change renames NewTypedDelayingQueue to NewTypedDelayingQueue to
stay consistent with the naming scheme in the package. A
NewTypedDelayingQueue constructor is kept for backwards compatibility
but marked as deprecated.

Kubernetes-commit: 45da5dc30ecf0ba4c4b44befd96b8617278c496b
2024-08-31 12:11:20 -04:00
Matthieu MOREL
acc5917341 fix: enable empty and len rules from testifylint on pkg package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>

Kubernetes-commit: f014b754fb5925dfbca6e27a44d0c3968b157e14
2024-06-28 21:20:13 +02:00
Lukasz Szaszkiewicz
9a760efea1 client-go/util/watchlist: intro CanUseWatchListForListRequest
Kubernetes-commit: 38fae9b799393f6fe17d07fb8148f05b1110859b
2024-06-10 18:03:47 +02:00
Lukasz Szaszkiewicz
14559c0fec client-go/consistencydetector: introduce CheckWatchListFromCacheDataConsistencyIfRequested
Kubernetes-commit: f7f3809c513cd051c2c45bbef0655cf5a3eceea2
2024-06-10 22:52:47 +02:00
Lukasz Szaszkiewicz
503a0905c0 client-go/util/consistencydetector: extend TestCheckListFromCacheDataConsistencyIfRequestedInternalHappyPath to work with unstructured list
Kubernetes-commit: a2a48a475b4c98daeea3f83b8a89aa070ea4082b
2024-06-07 10:55:01 +02:00
Lukasz Szaszkiewicz
2d885a2ed5 client-go/util/consistencydetector: refactor TestCheckListFromCacheDataConsistencyIfRequestedInternalHappyPath to work with unstructured data
Kubernetes-commit: c5904424b2b03cec1befaf16c55bb97df57669bc
2024-06-07 10:43:28 +02:00
Lukasz Szaszkiewicz
20d0a8ee82 client-go/consistencydetector: extend TestDataConsistencyChecker to test unstructured data
Kubernetes-commit: c8971c456f23627a91dc79bb8bc840a32dea611f
2024-06-07 10:33:11 +02:00
Lukasz Szaszkiewicz
82627741cb client-go/consistencydetector: refactor TestDataConsistencyChecker to work with unstructured data
Kubernetes-commit: d535f55ef9dd391712db09ac69dd083089457366
2024-06-06 14:14:33 +02:00
Lukasz Szaszkiewicz
bbe85a4a80 fix TestDriveCheckListFromCacheDataConsistencyIfRequested
Kubernetes-commit: 82794c4963144bf5298089030733f993a44f7c3b
2024-06-05 22:41:09 +02:00
Lukasz Szaszkiewicz
c7d706847a client-go/consistencydetector: handles the watch cache legacy case
Kubernetes-commit: fe8a2d222cc4208ee8f89fd2912d35cf58ec5941
2024-06-04 18:37:37 +02:00
Stephen Kitt
16552d4656 Use canonical json-patch v4 import
The canonical import for json-patch v4 is
gopkg.in/evanphx/json-patch.v4 (see
https://github.com/evanphx/json-patch/blob/master/README.md#get-it for
reference).

Using the v4-specific path should also reduce the risk of unwanted v5
upgrade attempts, because they won't be offered as automated upgrades
by dependency upgrade management tools, and they won't happen through
indirect dependencies (see
https://github.com/kubernetes/kubernetes/pull/120327 for context).

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 5300466a5c8988b479a151ceb77f49dd00065c83
2024-02-16 13:57:24 +01:00
Lukasz Szaszkiewicz
b7ea49a199 client-go/util/consistencydetector: add CheckListFromCacheDataConsistencyIfRequested
Kubernetes-commit: 48014bd7bdc331efea509a752694393ac929f270
2024-05-27 15:11:50 +02:00
Lukasz Szaszkiewicz
785fca481f client-go/util/consistencydetector: improve validation of list parameters (RV, ListOptions)
Kubernetes-commit: 327ae9866bda463ae43bd133a2522d5beea5ed35
2024-05-28 12:22:59 +02:00
Lukasz Szaszkiewicz
538b7809aa move checkWatchListDataConsistencyIfRequested back to client-go/tools/cache
Kubernetes-commit: cb44f83b3d500bb2ed29f7634095bc64c9b21729
2024-05-27 11:22:28 +02:00
Lukasz Szaszkiewicz
e6e45e172b client-go/util/consistencydetector: make the detector public
Kubernetes-commit: e421046f64c90b58577a79f92dd463ab03479d79
2024-05-27 11:16:17 +02:00
Lukasz Szaszkiewicz
92f0985ce1 client-go/util/consistencydetector: update after moving to the new package
Kubernetes-commit: faf5110c8a2394f9d098da6e5097ce6deed1b18b
2024-05-27 11:13:18 +02:00
Lukasz Szaszkiewicz
e428fc295c move client-go/tools/cache/reflector_data_consistency_detector to client-go/util/consistencydetector
Kubernetes-commit: 272dfc9d7e61481dfcdc4d6a021385d9cd85ba5f
2024-05-27 11:10:43 +02:00
Alvaro Aleman
d67dddfe90 Workqueue: Add generic versions that are properly typed
This change adds a generic version of the various workqueue types while
retaining compatibility for the existing exported symbols and constructors.
The generic variants are prefixed with `Typed` and the existing ones are
marked as deprecated to nudge people to transition without breaking
them.

Kubernetes-commit: 0c7370bb851c15825d30a516722139ccccca0cfc
2024-04-11 18:11:41 -04:00
Lan Liang
fa185a21db cleanup: delete rand.Seed(time.Now().UnixNano()) and using global number generator.
see https://tip.golang.org/doc/go1.20

Signed-off-by: Lan Liang <gcslyp@gmail.com>

Kubernetes-commit: dc992adad385ab631e4a528ee6a342ea71e7a379
2024-03-18 08:10:12 +00:00
Haibing Zhou
9c3db8681d workqueue: make queue as configurable
The default queue implementation is mostly FIFO and it is not
exchangeable unless we implement the whole `workqueue.Interface` which
is less desirable as we have to duplicate a lot of code. There was one
attempt done in [kubernetes/kubernetes#109349][1] which tried to
implement a priority queue. That is really useful and [knative/pkg][2]
implemented something called two-lane-queue. While two lane queue is
great, but isn't perfect since a full slow queue can still slow down
items in fast queue.

This change proposes a swappable queue implementation while not adding
extra maintenance effort in kubernetes community. We are happy to
maintain our own queue implementation (similar to two-lane-queue) in
downstream.

[1]: https://github.com/kubernetes/kubernetes/pull/109349
[2]: https://github.com/knative/pkg/blob/main/controller/two_lane_queue.go

Kubernetes-commit: 87b4279e07349b3c68f16f69a349a02bddd12f25
2024-02-16 12:09:37 -08:00
Erik Godding Boye
0b7086f721 feat: add csaupgrade option to upgrade subresource
Kubernetes-commit: 9633e25579dfa5449450875b9a238acc7cfac3e8
2024-02-24 15:44:21 +01:00
weilaaa
c609c97b33 use build-in max and min func to instead of k8s.io/utils/integer funcs
Kubernetes-commit: eb8f3f194fed16484162aebdaab69168e02f8cb4
2023-12-15 15:09:11 +08:00
Antonio Ojea
374e3638f2 workqueue unit tests to assert collapsing behaviors
Change-Id: If4bf54c3af603c17de49055960f9a76e7d38aab3

Kubernetes-commit: 8a31bb6786c2d3600bade49de7a64a026802bd6d
2023-09-21 10:48:01 +00:00
acejilam
a8fc969a34 Fix: null jsonpath serialization
Signed-off-by: acejilam <acejilam@gmail.com>

Kubernetes-commit: 9646ae5a9efb0eee7ac15577d113699700233017
2023-08-10 19:32:47 +08:00
Dave McCormick
e9b0103a41 Fix a race where a call to Shutdown was happening after ShutDownWithDrain() had performed the check q.isProcessing() && q.shouldDrain() and before waitForProcessing() has reached its Wait(). This is because waitForProcessing() is only checking the length part of the condition instead of both the length and whether we still need to drain.
It turned out that there were lots of unnecessary accessor functions being called locking and unlocking the cond which are not needed because Wait() automatically unlocks and locks the cond for us and best practice says we should run it in a for checking for the condition (so this is what I have done).

Kubernetes-commit: 2b12df56b0be93bc2cac7c5a66342c0ffaa72311
2023-07-24 22:40:54 +01:00