Commit Graph

491 Commits

Author SHA1 Message Date
Mayuka Channankaiah 34cfc51b85 Replace usage of deprecated ErrWaitTimeout with recommended method across all Pkgs
Kubernetes-commit: 6c56d2fd1bc54a7bcda84c8a83428877d9b39e96
2025-08-01 14:18:06 +05:30
Ben Luddy 36d7848a30 Configure JSON content type for generic webhook RESTClient.
Authorization, token authentication, imagepolicy admission, and audit webhooks configure RESTClients
that encode to JSON regardless of the ContentType of the provided rest.Config. Because this is
opaque to the RESTClient, configuring a ContentType other than "application/json" results in
requests with JSON-encoded bodies and a non-JSON media type in the Content-Type header. Webhook
servers that respect the Content-Type request header will be unable to decode an object from the
request body.

Explicitly overriding the ContentType of the provided rest.Config fixes this issue and is consistent
with how clients are constructed for conversion and admission webhooks.

Kubernetes-commit: ed07efbc57939afdf154afa80be35507d0a81d66
2025-07-15 11:28:06 -04:00
Antonio Ojea 8f1beab7b2 fix flake on TestStreamTranslator_WebSocketServerErrors
The metrics assertion race with the metric update, and since this
happens at the serverside, we use an active look to check the metrics
instead of expecting to be updated immidiatly.

Change-Id: I9a64b66301d5f4ac3df0c0a01de10602a20f89ea

Kubernetes-commit: f07dcd443d7335d09dc0de7a47485e2e6c87d725
2025-07-24 21:56:42 +00:00
Antonio Ojea 1c694e9979 websocket streamtranslator increament metrics before writing status
Test that assert on metrics use the returned status to sync the test, if
the metric is updated AFTER the state is returned the test will flake
because the assertion on the metric will race.

Change-Id: I317708a22cb47256c37dac3cab0463a2f925ad6b

Kubernetes-commit: 7ba22700bfd12cd32ff72db022e4b53ccda1deca
2025-07-28 21:59:08 +00:00
Antonio Ojea c8e4cae9a6 TestStreamTranslator_BlockRedirects use subtests
Reset metrics per status code also allow to  log the particular status
code that flake, in case the problem comes from an specific one.

Change-Id: I29f67d4c5d76449350f45049f45ce8325a2d0ddd

Kubernetes-commit: 0aea6a1e45d178371b44eabcaf0d318a01f9ac3d
2025-07-24 21:38:10 +00:00
Dan Winship ac3b5ee521 Port aggregated apiserver discovery to EndpointSlices
Co-Authored-by: Jordan Liggitt <liggitt@google.com>

Kubernetes-commit: d70e7e223cf5a02d0bdf557a57da11a276ec1e8c
2025-01-26 08:55:01 -05:00
Dan Winship c7df1daeb0 Add utilities for getting EndpointSlices for a Service
Co-Authored-by: Jordan Liggitt <liggitt@google.com>

Kubernetes-commit: 41dc2d3b0240c925110152c28fb41339d57d14e7
2025-05-22 13:30:11 -04:00
Marek Siarkowicz 3007d9c56b Account for caching and maximum object size when estimating LIST request
Kubernetes-commit: 99059895f4fdc7043689c3b81b1e4fc28c526ca9
2025-07-18 17:32:28 +02:00
Anish Ramasekar f6d9871507 Add generic config info custom collector
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>

Kubernetes-commit: f2c48ffec9e9395b0261893b1d2bafb80918cdc3
2025-07-17 01:04:20 -05:00
Marek Siarkowicz 7cfdd00464 Increase maxSeats for List requests
Kubernetes-commit: 66de1960a5d41ccd5631fed32fecf67536ec98e6
2025-07-17 17:48:41 +02:00
Marek Siarkowicz 478396c06d Add apiserver_resource_size_estimate_bytes metric
Kubernetes-commit: a091fa607eaecfa7b80cb0437db1d210aa587f98
2025-07-11 16:38:43 +02:00
Marek Siarkowicz f3eb956bcb Use object size estimation for non-recursive list
Kubernetes-commit: d8747d716e4b92930941a84409f24aef25035972
2025-07-15 11:08:51 +02:00
Marek Siarkowicz 0a86ef71af Use object size to estimate list cost assigning 1 sear per 100KB
Kubernetes-commit: 85adda5e68f07057a8b515779343f928ff61f471
2025-07-14 16:52:41 +02:00
xiaoweim af5056a3db Cleanup: Remove redundant detail messages in field.Required
Kubernetes-commit: 8632257c9340aeae824c99642376a78f69b3ea5d
2025-06-26 19:41:17 +00:00
Marek Siarkowicz cf27dab482 Estimate average size of objects in etcd and plug it into request cost estimator
Kubernetes-commit: ec78b8305ad392f6faf4e5247ea33ceabb484c3f
2025-06-13 16:34:42 +02:00
Davanum Srinivas 6db9ead72a 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
Davanum Srinivas 1ffdd2403f Eliminate AuditContext`s SetEventLevel
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
Co-Authored-By: Jordan Liggitt <liggitt@google.com>

Set event level during context init

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

Kubernetes-commit: 960a4939f2502f2a8f2b923203e9075354e4bdc0
2025-05-09 06:57:31 -04:00
sxllwx e6df86ea96 Fix API server crash on concurrent map iteration and write
Improve audit context handling by encapsulating event data and operations behind a structured API. Make
the Audit system more robust in concurrent environments by properly isolating mutable state. The cleaner
API simplifies interaction with audit events, improving maintainability. Encapsulation reduces bugs
by preventing direct manipulation of audit events.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
Co-Authored-By: Jordan Liggitt <liggitt@google.com>
Co-Authored-By: sxllwx <scottwangsxll@gmail.com>

Kubernetes-commit: 75afa1e0acfb309d984be14937a06f796f220cd6
2023-10-23 20:59:40 +08:00
Marek Siarkowicz 6811fdeb2d Unify should delegate list
Kubernetes-commit: 8fdd6fe4768d81da09f339c1dda831a05bb26f00
2025-03-20 11:08:37 +01:00
Marek Siarkowicz 91724cfd41 Change precedence order for continue and legacy exact match
This doesn't matter for shouldDelegateList, but matters when picking
source of RV. RV from continue takes precedence.

Kubernetes-commit: 7da942ca7486310893d4f11f3af062957f953555
2025-03-19 13:58:43 +01:00
Richa Banker ae08979dcc Replace StorageVersion API with aggregated discovery to fetch served resources by a peer for MVP
Co-authored-by: Joe Betz <jpbetz@google.com>

Co-authored-by: Jordan Liggitt <jordan@liggitt.net>

Kubernetes-commit: 8b2cee83c15b1fbc304123902e1bd8e8e06f0a12
2024-10-28 23:04:26 -07:00
Marek Siarkowicz cc5ef43352 Extract delegator.Helper interface to allow making delegate decision based on cache state
Kubernetes-commit: 984b475e74904dd61c10b23472798a21496edc8f
2025-03-17 15:46:02 +01:00
yongruilin 2b4f068bdb refactor: detach Info from apimachinery util version
- Remove `info` field from `Version` struct
- Modify `WithInfo` and `Info` methods to be deprecated
- Update version information retrieval to use base version info
- Simplify version information generation in compatibility tests
- Remove unnecessary version info passing in build and test scenarios

Kubernetes-commit: 14934b481ef6522d6c1003ded19002ea45abe5d1
2025-03-05 23:55:08 +00:00
Marek Siarkowicz 3cb2448d98 Fix detecting consistent read when watchcache starts handling continue
Kubernetes-commit: 8f83f2446a5e2f11eb751fb56067c663b51cfd12
2025-03-12 18:37:10 +01:00
novahe a2c8b5531e Fix test cases that may potentially cause a panic.
Kubernetes-commit: 9e53371ddaaeab4083fde45e43c803071238e686
2025-03-11 17:41:37 +08:00
Marek Siarkowicz 6ed423348f Simplify shouldDelegateList
When ResourceVersionMatch is set to NotOlderThan, there is no need to handle continue or resourceVersion="".
The validation in apimachinery will not pass and return:
* "resourceVersionMatch is forbidden when continue is provided"
* "resourceVersionMatch is forbidden unless resourceVersion is provided"

Kubernetes-commit: a0cc02e264ead76dfb0ae75a505e4d2e54219def
2025-03-12 18:20:47 +01:00
Marek Siarkowicz a64613cb08 Rename CacheProxy to CacheDelegator
Kubernetes-commit: 4c635ecf8250c7493481b9b8fb88e384de1b41db
2025-02-24 19:07:25 +01:00
xin.li afb79f83b3 fix wrong assertion on tests
Signed-off-by: xin.li <xin.li@daocloud.io>

Kubernetes-commit: bc4ae15d77beab23f321bf6547f82c04ba27c3fa
2025-02-22 12:39:01 +08:00
Wei Fu 2a04234bdc proxy: should add PingPeriod for websocket translator
IIUC, before using the translator handler, the ping data can be delivered from
the client to the runtime side since kube-apiserver does not parse any client
data. However, with WebSocket, the server responds with a pong to the client
without forwarding the data to the runtime side. If a proxy is present, it may
close the connection due to inactivity. SPDY's PingPeriod can help address this
issue.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
Co-authored-by: Antonio Ojea <aojea@google.com>

Kubernetes-commit: dc59c0246fb407dcf035afc224f63fcf0da8244e
2025-02-12 21:39:59 -05:00
Siyuan Zhang 9bb4aa730a Refactor compatibility version code
Replace DefaultComponentGlobalsRegistry with new instance of componentGlobalsRegistry in test api server.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

move kube effective version validation out of component base.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

move DefaultComponentGlobalsRegistry out of component base.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

move ComponentGlobalsRegistry out of featuregate pkg.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

remove usage of DefaultComponentGlobalsRegistry in test files.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

change non-test DefaultKubeEffectiveVersion to use DefaultBuildEffectiveVersion.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

Restore useDefaultBuildBinaryVersion in effective version.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

rename DefaultKubeEffectiveVersion to DefaultKubeEffectiveVersionForTest.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

pass options.ComponentGlobalsRegistry into config for controller manager and scheduler.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

Pass apiserver effective version to DefaultResourceEncodingConfig.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

change statusz registry to take effective version from the components.

Signed-off-by: Siyuan Zhang <sizhang@google.com>

Address review comments

Signed-off-by: Siyuan Zhang <sizhang@google.com>

update vendor

Signed-off-by: Siyuan Zhang <sizhang@google.com>

Kubernetes-commit: 8fc3a33454ba38783bb63de41ecf5343e2ced67c
2024-12-20 07:03:03 +00:00
Davanum Srinivas 0a703e3517 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
Marek Siarkowicz b43177846d Refactor shouldDelegateList
Kubernetes-commit: e5a3bdb3a71575af0d165e8b08cfaba7d572b802
2024-12-31 11:57:43 +01:00
Madhav Jivrajani 7c924dc3c8 webhook: alter regex to account for x509sha1 GODEBUG removal
go1.24 removes the x509sha1 GODEBUG variable, and with it the
support for SHA-1 signed certs. This commit alters the regex
in unit tests to account for that and prep for go1.24.

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: cff0f4009f17c84141553c143872d47756209f4d
2024-12-30 13:39:17 -08:00
Jefftree ada3ee1529 add test for inmemory response writer
Kubernetes-commit: bf1b9c45ea976a9e871b35b644f34ec508f3d57d
2024-10-25 20:54:18 +00:00
Patrick Ohly b84662911c 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
Ben Luddy 0b5852eb9a Wire serving codecs to CBOR feature gate.
Integration testing has to this point relied on patching serving codecs for built-in APIs. The
test-only patching is removed and replaced by feature gated checks at runtime.

Kubernetes-commit: 439d2f7b4028638b3d8d9261bb046c3ba8d9bfcb
2024-11-01 16:05:32 -04:00
Ben Luddy ca9c3d965e 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
Kubernetes Prow Robot 4bece4d457 Merge pull request #128196 from richabanker/move-version
Move k8s.io/apiserver/pkg/util/version to component-base

Kubernetes-commit: 119f114f012ae6d1cd851bdb2c3f849307e83258
2024-10-29 18:49:35 +00:00
Ben Luddy f27bb5491e Wire test-only feature gate for CBOR serving.
To mitigate the risk of introducing a new protocol, integration tests for CBOR will be written using
a test-only feature gate instance that is not wired to runtime options. On alpha graduation, the
test-only feature gate instance will be replaced by a normal feature gate in the existing apiserver
feature gate instance.

Kubernetes-commit: 0cad1a89b6721308746cc1a12f12de31a259a0d3
2024-10-23 16:36:25 -04:00
Omer Aplatony 965243019f Use PollUntilContextTimeout in flowcontrol
Signed-off-by: Omer Aplatony <omerap12@gmail.com>

Kubernetes-commit: 9fe3f368b1813b491f9b1265547235f309ff87e9
2024-10-08 10:25:15 +03:00
Devesh Goyal b2a5ee84cf Updated width.go
Kubernetes-commit: ed0c2b4f3d33fe7f165ff2c39034ca062c75f964
2024-08-25 02:12:29 +05:30
Richa Banker 50dafb8926 reset err in resolveServingLocation() when the req can be served by local apiserver
Kubernetes-commit: 6e66a359822a988f9acd7062c3731559535abcd5
2024-09-27 16:54:08 -07:00
Richa Banker df45eb6de5 refactor peerproxy_handler and add unit test
Kubernetes-commit: 9c65b79ea3b81859698f0f2613c82de99154755d
2024-01-24 19:48:51 -08:00
Jefftree f900b71720 Move inmemoryresponsewriter into own package
Kubernetes-commit: f67e15a26f5958b1ebf07a2590e98889a987677d
2024-09-30 21:11:53 +00:00
Richa Banker 8c1054e51e use structured logging wherever possible
Kubernetes-commit: 45a47d634569acad9022733ba35131088e9575e6
2024-09-27 16:54:08 -07:00
Richa Banker 40680bab4c Do not mark errorFetchingAddressFromLease, in case when the there's no address being fetched from the lease object
Kubernetes-commit: ac3fd5c634d2d9fd2e4011294f152e64f72d205b
2024-09-27 16:37:46 -07:00
Matthieu MOREL aaeee2a449 fix: enable error-nil and nil-compare rules from testifylint in module `k8s.io/apiserver`
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Kubernetes-commit: 09274182e225fcf4df9e4a3d54fd96fc03de3bdf
2024-09-27 07:29:09 +02:00
Matthieu MOREL c6ba9681f7 fix: enable contains rule from testifylint in module `k8s.io/apiserver`
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Kubernetes-commit: 3b92b9f84d62550a62890d8d3f6a57d96fc70ccc
2024-09-22 11:57:24 +02:00
Matthieu MOREL b489c4ea4e fix: enable error-is-as rule from testifylint in module `k8s.io/apiserver`
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Kubernetes-commit: 0dfc6e2843f913b26c9382144fd2381f4b536bf0
2024-09-22 12:21:19 +02:00
Abhishek Kr Srivastav 17ab6c21d5 Fix Go vet errors for master golang
Co-authored-by: Rajalakshmi-Girish <rajalakshmi.girish1@ibm.com>
Co-authored-by: Abhishek Kr Srivastav <Abhishek.kr.srivastav@ibm.com>

Kubernetes-commit: 95860cff1c418ea6f5494e4a6168e7acd1c390ec
2024-09-12 18:15:22 +05:30