Commit Graph

316 Commits

Author SHA1 Message Date
Harish Kuna 5e9ddf231e Fix -Consistent paginated lists serve from cache
Kubernetes-commit: d4a4a1d881ea46857afe67d3ca89d106fa59c6b1
2025-06-05 20:38:07 +00: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 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 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 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 f76f81aa6f Test recursive in TestGetListCacheBypass and separate overrides
Kubernetes-commit: 6d3bff83213b35797b23e89c90bfe939dd30c2cd
2025-03-04 20:07:41 +01:00
Marek Siarkowicz 3cb2448d98 Fix detecting consistent read when watchcache starts handling continue
Kubernetes-commit: 8f83f2446a5e2f11eb751fb56067c663b51cfd12
2025-03-12 18:37:10 +01:00
Marek Siarkowicz 36c1a58d7e Fix typo and pass the environment variable required to enable watchcache consistency checking in GCE tests
Kubernetes-commit: 8b0294daed236dcaf2b2f74ad4a38405118ebbaa
2025-03-13 11:55:23 +01: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 23e9b2c9d4 Implement consistency checking
Kubernetes-commit: e4d73c56cd055a6e3a23068bd70c424579df40fe
2025-02-27 17:53:06 +01:00
Marek Siarkowicz 4305a14262 Separate compactWatchCache from increaseRV
Kubernetes-commit: 15cb82b3b3fa95ba5b914a5a02ac01d42eda892f
2025-02-25 14:44:50 +01:00
Marek Siarkowicz f422062046 Pass storage.ListOptions to WaitUntilFreshAndList
Kubernetes-commit: e6cf9dd1663a9a54fa673873e8e97641f69bcefd
2025-02-19 11:20:04 +01:00
Marek Siarkowicz 79ec45326d Run lists tests in subtests
Kubernetes-commit: 7a84e7630f91014fa3b632d8800e9a943003001c
2025-03-03 20:50:37 +01:00
Marek Siarkowicz 9e523945a2 Remove limit support from btree store
We cannot use limit as it would apply it before filtering, which is done
in cacher. Limit is not currently used, but let's remove it to be save,
until filtering is implemented in store.

Kubernetes-commit: 168c338f7cb44a08f3d1a7e1d0e72cac241e9a29
2025-02-25 19:17:30 +01:00
Marek Siarkowicz 3ad93853da Move GetCurrentResourceVersion to storage.Interface
Kubernetes-commit: fea89f25d1bfd7290bb0165f49a6d288ab5f717a
2025-02-24 19:49:45 +01:00
Marek Siarkowicz a4587170bd Move watch progress to separate package.
Kubernetes-commit: 740db0f01d9bceaa7bd6c0b6c5e5f96fc78c04dd
2025-02-25 13:53:17 +01:00
Marek Siarkowicz a64613cb08 Rename CacheProxy to CacheDelegator
Kubernetes-commit: 4c635ecf8250c7493481b9b8fb88e384de1b41db
2025-02-24 19:07:25 +01:00
Lukasz Szaszkiewicz 3aea7778be storage/cacher/ready: dynamically calculate the retryAfterSeconds
retryAfterSeconds is based on the time elapsed since the state (ready, unready) was last changed.

Kubernetes-commit: 04f0bd4e83bbc0a24b8a924333544be86b252c97
2024-10-14 08:17:14 +02:00
Marek Siarkowicz 09c0e7d0cd Add snapshotting of watch cache behind a feature gate
Kubernetes-commit: 2de2093bcef6544ef17c84116fbd751fc429820a
2025-02-19 17:03:48 +01:00
Marek Siarkowicz d522031d97 Ensure that btree threadedStoreIndexer implements orderedLister
Kubernetes-commit: 99881453838a63730fb34b6bd02775ae08320184
2025-02-19 11:47:26 +01:00
Antoni Zawodny efe7a1b26d Add watch cache capacity upper bound adjusting logic
Kubernetes-commit: 2173a0fafd448e55b7738b88fbbab392125dd975
2025-02-21 15:07:01 +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
张可10140699 9da16fa551 Fix non-recursive list should also read RequestWatchProgress feature when consistent list from cache is enabled
Kubernetes-commit: bdf2e2d0646fcb6fa56289d85222e2de0b686244
2025-02-20 08:39:36 +08:00
Lukasz Szaszkiewicz 23e8a6cc2f cacher: decrease the running time of TestConsistentReadFallback
Kubernetes-commit: 601c0e359dc959bbfaf42c5d8a8a0a9a2175db74
2025-01-28 13:31:43 +01:00
Lukasz Szaszkiewicz 8a149c9296 cacher/cacher_whitebox_test: newTestCacherWithoutSyncing allow passing a clock
Kubernetes-commit: cfd6d9a2b4476d4256959dc2ebdd517f20191ea3
2025-01-27 19:51:35 +01:00
Marek Siarkowicz 0167eb5d20 Deprecate WatchFromStorageWithoutResourceVersion
Around the 1.31 release, we discovered that a change introduced in 1.27 allowead
clients to open WATCH requests directly to etcd. This had detrimental consequences,
enabling abusive clients to bypass caching and overwhelm etcd.
Unlike the API server, etcd lacks protection against such behavior.

To mitigate this, we redirected all WATCH requests to be served from the cache.
The WatchFromStorageWithoutResourceVersion feature gate was retained as an escape hatch.
However, since we have no plans to allow direct WATCH requests to etcd again,
this flag is now obsolete.

Direct WATCH requests to etcd offer no advantage, as they don't provide stronger
consistency guarantees. WATCH operations are inherently inconsistent; unlike LIST
operations, they do not confirm the resource version with a quorum. While Kubernetes
uses the WithRequireLeader option on WATCH requests to prevent maintaining connections
to isolated etcd members, the API server provides the same level of guarantee through
its health checks, which fail if it cannot connect to etcd member.  Therefore,
the WatchFromStorageWithoutResourceVersion feature gate can be deprecated and removed.

Kubernetes-commit: 065bf2004d27e5e3f1be3c0f128347d4060d8954
2025-01-31 11:49:28 +01:00
张可10140699 e802cf6daf remove duplicate getAttrsFunc calls to reduce temporary memory allocations
Kubernetes-commit: 479ff5a02b026caec40e8262785e8ffffb42085a
2025-01-15 10:15:02 +08:00
Marek Siarkowicz a6c0914bb9 Only test requests that pass validation
Kubernetes-commit: 1b2bacda5bd978b68a6dc704606495b29b181690
2025-01-09 12:55:45 +01:00
Marek Siarkowicz 74be087390 Extract and unify cache bypass logic by creating a CacheProxy struct
Kubernetes-commit: 4a4fc9da801f299176c7200e66224aa79b1c0817
2024-12-31 14:04:00 +01:00
Marek Siarkowicz b43177846d Refactor shouldDelegateList
Kubernetes-commit: e5a3bdb3a71575af0d165e8b08cfaba7d572b802
2024-12-31 11:57:43 +01:00
Marek Siarkowicz 3c47ed7b1d Test all possible combinations of input for shouldDelegateList
Kubernetes-commit: fe895563d92f55068c6090e29dfbd21291b203d8
2024-12-31 11:42:28 +01:00
Marek Siarkowicz 8161d73803 Add benchmarking of namespace index
Kubernetes-commit: 13a21d5854855671ca0256e39b1657dacd301371
2024-11-05 10:32:59 +01:00
Marek Siarkowicz fd21d18170 Improve benchmark to handle multiple dimensions
Kubernetes-commit: 4a0578e3dee093aec23e16556ac8fb8642060362
2024-11-05 10:32:59 +01:00
Marek Siarkowicz 62c90b1dff Extract list response struct to manage all the response fields
Kubernetes-commit: 78a6402755905f14d72ee47fdb1e169dbdaa6853
2024-11-24 13:10:17 +01:00
Alvaro Aleman 84b3c4c640 Use generic btree in watchcache
This change makes us use the generic btree available in newer versions
of github.com/google/btree. This avoids a bunch of type assertions and
makes the code easier to read.

Kubernetes-commit: b1cb471982b74c13c26dbcc0f4e1b5ae92ea47e6
2024-11-19 22:04:08 -05:00
Antoni Zawodny 0dcf3e9d26 Configure watch cache history window based on request timeout
Kubernetes-commit: 4a2b7ee5699331df31b7483be082c201a1e7f51f
2024-12-13 15:40:03 +01:00
Marek Siarkowicz e85d45c0a4 Use btree for watch cache storage to serve LIST more efficiently
Can be disabled via BtreeWatchCache feature flag.

Kubernetes-commit: 5ea427ebb508ce2871d4d0f9869959275c0d3bce
2024-08-17 11:01:41 +02:00
Wojciech Tyczyński 0679efd5ba Fix TestCacherDontMissEventsOnReinitialization test
Kubernetes-commit: d35ea217fa7541a2b1942aaf533697a2e4e7a222
2024-10-31 12:33:04 +01:00
Marek Siarkowicz 518e8ed25c Adding tests for using indexers in tests
Kubernetes-commit: 711772a1e15288d813a830780317a134df9acb5c
2024-08-22 20:04:37 +02:00