Commit Graph

904 Commits

Author SHA1 Message Date
Marek Siarkowicz dda2fcb797 Expose compaction revision from compactor
Kubernetes-commit: 03e32bd260fbd77351e1b528f22a69a8eaece9ee
2025-07-09 16:22:19 +02:00
Marek Siarkowicz 34f5472b35 Add test for compactor
Kubernetes-commit: 5e3ea8e279c51a0b4fcc996d244d2c5593935816
2025-07-09 16:29:55 +02:00
Marek Siarkowicz 2f077fcbca Add testing compaction in storage List tests
Kubernetes-commit: c53b41e98c2e9248916704f36443de87cbee64e0
2025-07-08 11:19:59 +02:00
Benjamin Elder bf8c1a6d90 storage/etcd3: add back missing errcheck
lost in recent refactoring.

Kubernetes-commit: 838f3afc5219640725922266b689c7d24fbdf804
2025-07-07 17:37:36 -07:00
PatrickLaabs d0ee71ec17 chore: second depr. pointer pkg replacement for apiserver
Kubernetes-commit: fe61e825e046d793d64fc0686110212dacf8231e
2025-07-06 11:09:16 +02:00
liuxu ab47d6f39c remove apiserver_storage_objects metrics after crd deleted
Kubernetes-commit: 8c6c7df736dff27903bc03a1b9a42c1e2c84c7ee
2025-07-03 09:57:15 +08:00
Marek Siarkowicz 67c4a8a9ee Add benchmark for SizeBasedListCostEstimate feature
Kubernetes-commit: 1639b090839b37ab08c1d90d62f2c7a4c44faba4
2025-06-25 15:50:34 +02:00
Marek Siarkowicz df850b5a51 Override getKeys when cacher is enabled
Kubernetes-commit: e2c6b7fdf97206cc60d6c5f0e1cb306652ec189a
2025-06-23 16:35:06 +02:00
Marek Siarkowicz b805c4d851 Run background cleanup goroutine
Kubernetes-commit: 7cb241799935745277125db033ae217fe64e322c
2025-06-18 17:24:17 +02: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
Marek Siarkowicz eaf6e48501 Handle consistent LIST in watch cache to avoid incorrect semantics while setting ResourceVersion on options
Kubernetes-commit: 292679a28ae472da29c5d860afdb5c2250637d31
2025-06-06 17:16:46 +02:00
Lukasz Szaszkiewicz a77ab41bc0 client-go/reflector: stop exposing UseWatchList (#132453)
* client-go/reflector: stop exposing UseWatchList

* apiserver/cacher: stop setting reflector.UseWatchList

* test/integration/watchlist: fix TestReflectorWatchListFallback

Kubernetes-commit: b8b3984874e930c92057589fd1a7668dbdffc117
2025-06-25 13:45:59 +00:00
PatrickLaabs fdccb8b2dc fixing large resourceversion and limit for storages
Kubernetes-commit: ccdef28acd3a286e8d62222ddf804ae4042764e5
2025-06-18 16:22:13 +02:00
Lukasz Szaszkiewicz 0d3a31d996 apiserver/storage/cacher/listwatcher: error when the WatchList FG is disabled
Kubernetes-commit: 7e0d71fc14bcbe1fae42ccc91f2d48fc9b99a049
2025-06-25 08:50:03 +02:00
Lukasz Szaszkiewicz 0e36545f56 apiserver/cacher: properly wire listwatch options to the listwatcher
Kubernetes-commit: dce69afadeaf3fc8c98d1dfd56394fb77d52225b
2025-06-24 10:55:06 +02:00
Marek Siarkowicz baef40d3ec Move UnsafeCorruptObjectDeletion outside of etcd3.New function
By returning *store instead of storage.Interface we can expose Close()
function so in the future we can register it to destroyFunc in
newETCD3Storage.

Kubernetes-commit: 72305f82f9a20315d7ff4904a840bfd56478d44a
2025-06-23 10:50:06 +02:00
Marek Siarkowicz 9b695a5efa Validate requests sent to etcd in TestList "test List with limit" scenario
This adds a regression test to detect fallback to etcd as discovered in https://github.com/kubernetes/kubernetes/issues/132132.

Kubernetes-commit: 4cb6d3d77617f141fefd4994910380c095dac1ad
2025-06-12 11:33:02 +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
Harish Kuna 80cef81846 Fix -Consistent paginated lists serve from cache
Kubernetes-commit: 2004ee50f5da851b08cca95b4a9c12c84794559d
2025-06-05 20:38:07 +00:00
Lukasz Szaszkiewicz 8162f5ea9d apiserver/handlers/watch: stop encoding initialEventsListBlueprint (#132326)
* apiserver/handlers/get: remove constructing versionedList

* endpoints/handlers/response: rm watchListTransformer

* endpoints/handlers/watch: unwire watchListTransformer

* storage/cacher: rm documentation about caching the serialization of bookmark events

Kubernetes-commit: fc198b92c0d5cece06fd4ecc24f6142532beff37
2025-06-16 16:02:59 +02:00
Aleksander Mistewicz 7cd49caffc Add context to Count()
Passing the same context will let us associate etcd traces with those
from apiserver.

Signed-off-by: Aleksander Mistewicz <amistewicz@google.com>

Kubernetes-commit: 96b39187c5fac62e462dc348ccc1e3938464d9e1
2025-01-15 11:42:29 +01:00
Marek Siarkowicz 784d2892e6 Gradute ResilientWatchCacheInitialization to GA
Kubernetes-commit: 741d0e2b81a0820892db18b90f5b691a19676010
2025-05-27 13:17:32 +02:00
Davanum Srinivas b887c9ebec Drop usages of deprecated otelgrpc methods
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 7c0f968ab256486b524ea37014ccf580b12c73e4
2025-05-23 19:40:36 -07:00
Marek Siarkowicz a559cb8be1 Unify references to group resource in metrics
Skip apiserver_storage_objects as it's a stable metrics that doesn't
have "group" label. As defined in KEP-1209 adding a label is considered
a breaking change so this change should be done via deprecation and
introduction of new metric.

Tested via:
```
kubectl get --raw /metrics | grep -i apiservice | grep -v APIServiceRegistrationController | grep -v aggregator_unavailable_apiservice | python3 -c "import sys; print('\n'.join([k+' ' + v for k,v in {a.split('{')[0]:'{'+a.split('{')[1].split('}')[0]+'}' for a in sys.stdin.readlines() if '#' not in a and '_sum' not in a and '_bucket' not in a}.items()]))"
```

Before:
```
apiserver_cache_list_fetched_objects_total {index="",resource_prefix="/apiregistration.k8s.io/apiservices"}
apiserver_cache_list_returned_objects_total {resource_prefix="/apiregistration.k8s.io/apiservices"}
apiserver_cache_list_total {index="",resource_prefix="/apiregistration.k8s.io/apiservices"}
apiserver_longrunning_requests {component="apiserver",group="apiregistration.k8s.io",resource="apiservices",scope="cluster",subresource="",verb="WATCH",version="v1"}
apiserver_request_body_size_bytes_count {resource="apiservices.apiregistration.k8s.io",verb="create"}
apiserver_request_duration_seconds_count {component="apiserver",dry_run="",group="apiregistration.k8s.io",resource="apiservices",scope="resource",subresource="",verb="POST",version="v1"}
apiserver_request_sli_duration_seconds_count {component="apiserver",group="apiregistration.k8s.io",resource="apiservices",scope="resource",subresource="",verb="POST",version="v1"}
apiserver_request_total {code="201",component="apiserver",dry_run="",group="apiregistration.k8s.io",resource="apiservices",scope="resource",subresource="",verb="POST",version="v1"}
apiserver_response_sizes_count {component="apiserver",group="apiregistration.k8s.io",resource="apiservices",scope="cluster",subresource="",verb="LIST",version="v1"}
apiserver_selfrequest_total {resource="apiservices",subresource="",verb="POST"}
apiserver_storage_events_received_total {resource="apiservices.apiregistration.k8s.io"}
apiserver_storage_list_evaluated_objects_total {resource="apiservices.apiregistration.k8s.io"}
apiserver_storage_list_fetched_objects_total {resource="apiservices.apiregistration.k8s.io"}
apiserver_storage_list_returned_objects_total {resource="apiservices.apiregistration.k8s.io"}
apiserver_storage_list_total {resource="apiservices.apiregistration.k8s.io"}
apiserver_storage_objects {resource="apiservices.apiregistration.k8s.io"}
apiserver_watch_cache_events_dispatched_total {resource="apiservices.apiregistration.k8s.io"}
apiserver_watch_cache_events_received_total {resource="apiservices.apiregistration.k8s.io"}
apiserver_watch_cache_initializations_total {resource="apiservices.apiregistration.k8s.io"}
apiserver_watch_cache_resource_version {resource="apiservices.apiregistration.k8s.io"}
apiserver_watch_events_sizes_count {group="apiregistration.k8s.io",kind="APIService",version="v1"}
apiserver_watch_events_total {group="apiregistration.k8s.io",kind="APIService",version="v1"}
etcd_request_duration_seconds_count {operation="listWithCount",type="/registry/apiregistration.k8s.io/apiservices/"}
etcd_requests_total {operation="listWithCount",type="/registry/apiregistration.k8s.io/apiservices/"}
watch_cache_capacity {resource="apiservices.apiregistration.k8s.io"}
```

After:
```
apiserver_cache_list_fetched_objects_total {group="apiregistration.k8s.io",index="",resource="apiservices"}
apiserver_cache_list_returned_objects_total {group="apiregistration.k8s.io",resource="apiservices"}
apiserver_cache_list_total {group="apiregistration.k8s.io",index="",resource="apiservices"}
apiserver_longrunning_requests {component="apiserver",group="apiregistration.k8s.io",resource="apiservices",scope="cluster",subresource="",verb="WATCH",version="v1"}
apiserver_request_body_size_bytes_count {group="apiregistration.k8s.io",resource="apiservices",verb="create"}
apiserver_request_duration_seconds_count {component="apiserver",dry_run="",group="apiregistration.k8s.io",resource="apiservices",scope="resource",subresource="",verb="POST",version="v1"}
apiserver_request_sli_duration_seconds_count {component="apiserver",group="apiregistration.k8s.io",resource="apiservices",scope="resource",subresource="",verb="POST",version="v1"}
apiserver_request_total {code="201",component="apiserver",dry_run="",group="apiregistration.k8s.io",resource="apiservices",scope="resource",subresource="",verb="POST",version="v1"}
apiserver_response_sizes_count {component="apiserver",group="apiregistration.k8s.io",resource="apiservices",scope="cluster",subresource="",verb="WATCH",version="v1"}
apiserver_selfrequest_total {group="apiregistration.k8s.io",resource="apiservices",subresource="",verb="WATCH"}
apiserver_storage_events_received_total {group="apiregistration.k8s.io",resource="apiservices"}
apiserver_storage_list_evaluated_objects_total {group="apiregistration.k8s.io",resource="apiservices"}
apiserver_storage_list_fetched_objects_total {group="apiregistration.k8s.io",resource="apiservices"}
apiserver_storage_list_returned_objects_total {group="apiregistration.k8s.io",resource="apiservices"}
apiserver_storage_list_total {group="apiregistration.k8s.io",resource="apiservices"}
apiserver_storage_objects {resource="apiservices.apiregistration.k8s.io"}
apiserver_watch_cache_events_dispatched_total {group="apiregistration.k8s.io",resource="apiservices"}
apiserver_watch_cache_events_received_total {group="apiregistration.k8s.io",resource="apiservices"}
apiserver_watch_cache_initializations_total {group="apiregistration.k8s.io",resource="apiservices"}
apiserver_watch_cache_resource_version {group="apiregistration.k8s.io",resource="apiservices"}
apiserver_watch_events_sizes_count {group="apiregistration.k8s.io",resource="apiservices",version="v1"}
apiserver_watch_events_total {group="apiregistration.k8s.io",resource="apiservices",version="v1"}
etcd_bookmark_counts {group="apiregistration.k8s.io",resource="apiservices"}
etcd_request_duration_seconds_count {group="apiregistration.k8s.io",operation="listWithCount",resource="apiservices"}
etcd_requests_total {group="apiregistration.k8s.io",operation="listWithCount",resource="apiservices"}
watch_cache_capacity {group="apiregistration.k8s.io",resource="apiservices"}
```

Kubernetes-commit: f712b01ddb55f6569b930ca714499051ba8cb311
2025-05-19 11:41:09 +02:00
Marek Siarkowicz 6764e31cac Separate getList and watch errors to prevent TestGetCacheBypass flakes
The TestGetCacheBypass requires watch cache to be initialized after
which it will want backend to return errors to check what requests are
cached and which are not.

The watch cache is marked as ready after a list succeeds, but before a watch request is executed.
If watch request fail it will immidietly flip back to unready.

Injecting error after watch cache was ready didn't guarantee that watch
request started, sometimes causing watch to be called after and fail.
This immidietly caused the watch cache to be again unready for the rest
of the test.

The fix is just to separate failure injection for List and Watch
responses.

Kubernetes-commit: 70e05132645d5c49cf0ac61a3ae8869dc60f0bde
2025-05-14 15:52:06 +02:00
Jordan Liggitt 067a2139bb Set non-experimental WatchProgressNotifyInterval config field
Kubernetes-commit: 6b0ebedccc19f3fbf877487cffa34c3694d0c275
2025-03-27 11:54:39 -04:00
Karl Isenberg 46dd96ca03 refactor: Stop using ioutil in apiserver
- The ioutl package is deprecated. Migrate to os package functions.

Kubernetes-commit: f93e4645c18c6f56bfddc158ef7b3f674b3c41dd
2025-05-08 11:28:52 -07:00
Ali Abbasi Alaei b6cfd80a0d pkg/storage/cacher/cacher_whitebox_test: deflake TestWatchNotHangingOnStartupFailure when ResilientWatchCacheInitialization is on
Kubernetes-commit: 2073ba2372b2cd1c53b327a50656a2cdd13decba
2025-05-01 16:55:49 -04:00
Wojciech Tyczyński fc69168d19 Fix etcd3 watcher flake
Kubernetes-commit: c3bb59d078a023153c6ea0c9a93e535b48f2557d
2025-04-24 11:32:49 +02:00
Wojciech Tyczyński 4f42467c04 Simplify etcd3 watcher
Kubernetes-commit: 6d6abaab7d1b8f288ed949a115cc769d83bf0fe2
2025-03-24 14:02:07 +01:00
Wojciech Tyczyński b9e86eb851 Fix race for sending errors in watch
Kubernetes-commit: c8c2844aaf1d04835624ff2d46417492e10dec11
2025-03-24 14:02:07 +01:00
Jordan Liggitt 1776f0c3f2 Parallelize cacher list tests
Kubernetes-commit: eca90dab3f553c5794e780c67e17ae75d9acb65b
2025-03-31 15:17:04 -04:00
Marek Siarkowicz e228aeaf39 Don't start etcd for skipped test
Kubernetes-commit: 1a15d582ae5fc84177f305d93ff473cca5de6f93
2025-03-31 21:06:54 +02:00
Marek Siarkowicz 29a5d82129 Stop cacher in TestWatchStreamSeparation to speed up shutdown
Kubernetes-commit: 75186095c58630fde0b3f89892c69c8ef91fffab
2025-03-31 21:28:21 +02:00
Marek Siarkowicz 30b60eb0a6 Fix flake, non-consistent list doesn't give any guarantees about staleness
Kubernetes-commit: 38d5cb368dd95b7f185dbba97fc3e193f48a83f2
2025-03-31 08:10:42 +02:00
Marek Siarkowicz aed144f141 Ensure that cacher is terminated in TestGetListRecursivePrefix
Kubernetes-commit: 9b5c4504ee49c366be3d7c806482ef4665dc5f70
2025-03-31 18:17:08 +02:00
Marek Siarkowicz 6811fdeb2d Unify should delegate list
Kubernetes-commit: 8fdd6fe4768d81da09f339c1dda831a05bb26f00
2025-03-20 11:08:37 +01:00
Marek Siarkowicz 5a059075db Serve LISTs with exact RV and continuations from cache
Kubernetes-commit: f82c9e56d928d1028d4b298578f275a2e5e69490
2024-07-03 21:36:51 +02:00
Marek Siarkowicz fa558b198a Create Snapshotter interface to fake the implementation
Kubernetes-commit: 3edeb60c089106229b582a8c6800388de433426a
2025-03-19 14:04:47 +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
Marek Siarkowicz edd1d1f6ba Extend shouldDelegateList testing incorportating state of cacher
Kubernetes-commit: 929a9c0cad9b5c2c411a325fd4f356a2b5e01f13
2025-03-19 12:23:08 +01:00
Marek Siarkowicz 50f48ce4b3 Implement watchcache returning error from etcd that caused cache reinitialization
Kubernetes-commit: c09d87f79c90a5ebb0ef6a99abd13dec82b497e3
2025-03-18 16:48:33 +01:00
Marek Siarkowicz c59961a007 Test continue with negative RV for reading consistent RV
Kubernetes-commit: 6d21d8f2376b6e25064b10148b4f416e8d89a508
2025-03-17 12:10:54 +01:00
Marek Siarkowicz 4da0062093 Fix missing recursive in consistency check, enable panic on failed check and fix typo in logs
Kubernetes-commit: 4f1912abf2d139c57036c5333f62bd5bddd289fe
2025-03-17 19:24:16 +01: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
Marek Siarkowicz 7a33f524c6 Use ValidateListOptions in watch cache
Kubernetes-commit: 9e7c080b863896ffbe9eff2a7edc63aa72ec30cf
2025-03-10 14:29:24 +01:00
Marek Siarkowicz 6f6da8e97b Add test cases for negative resource version in TestList
Kubernetes-commit: c4d77a07993302057441a886125c1c887e7869f1
2025-03-14 12:22:17 +01:00
Marek Siarkowicz a67992576e Test bypass for negative RV
Kubernetes-commit: 58d9b5c7b6467bb2cb14d49247cdada02e8f4a83
2025-03-14 14:34:43 +01:00
Marek Siarkowicz 3a2e1b53e5 Simplify bypass test by just testing shouldDelegateList function
Kubernetes-commit: d263344a9b400890409166c5823598a92bbb79fb
2025-03-14 14:26:44 +01:00
Marek Siarkowicz 6ace22f694 Fix flaky RunTestConsistentList
Noticed that cache might not nesseserly observe the write causing test
to flake. Fixed that changing the logic to require LessOrEqual of
writeRV instead of equal to writeRV. Also added comments explaining
edge cases.

Kubernetes-commit: 86169a7a1e09c120cadafc0213afbf9630f0d8af
2025-03-14 13:45:55 +01:00