Commit Graph

139 Commits

Author SHA1 Message Date
Wojciech Tyczyński b028a2ea8d Unify merge GetToList and List storage methods to single GetList
Kubernetes-commit: f3d56369f71f5106eeec8300e77bd69b172733da
2022-02-10 10:15:29 +01:00
Wojciech Tyczyński 9f8f72fea9 Change storage.Interface to utilize recurisve parameter
Kubernetes-commit: 3016b3d8f868a3041c7cb86695de09d7ab27cf3b
2022-02-10 09:58:31 +01:00
Madhav Jivrajani ffc1b941d4 cacher: Minor cleanup and refactor of code and tests
* Remove linter warnings.
* Cancel contexts to avoid leaks.
* Rename a few XXXThreadUnsafe to XXXLocked to
  maintain consistency.
  * A few are still called XXXThreadUnsafe mainly
    because those are safe to be called from the
    perspective that only one gorotuine will access
    them - not really called under a lock.

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

Kubernetes-commit: c3081b48759db1f05a446f2acca7e05c4511ce2e
2022-02-10 13:44:34 +05:30
Madhav Jivrajani 4f2ee5cf42 cacher: Use watchCacheInterval to reduce lock contention
- Modify GetAllEventsSinceThreadUnsafe to return a watchCacheInterval
- Modify Watch() to compute a watchCacheInterval rather than a slice
  of all "initEvents" and pass this interval to process()
- Use interval::Next() to obtain events to process rather than obtain
  them all at once
- Modify tests accordingly to use interval
- On invalidation, stop processing and stop the watch.
- Make indexValidator injectable for testing
- Add unit test for verifying the behaviour of stopping the watch.

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

Kubernetes-commit: 7f2aa7ad3a61a52d0a780f904b291d063399c28a
2021-10-05 15:52:09 +05:30
Wojciech Tyczyński 067689be43 Graduate EfficientWatchResumption feature to GA
Kubernetes-commit: b7257a4d6a3f2382f4753322ec6d3458410b04f9
2021-12-10 10:20:51 +01:00
Wojciech Tyczyński b4935b065f Slightly improve reliability of storage List tests.
Kubernetes-commit: 8ca6c5922b9a0bafa8c83617d6930b981430334e
2021-12-10 12:05:32 +01:00
Wojciech Tyczyński 0002a597cd Unify List and GetToList functions of cacher.
Kubernetes-commit: c86543d9cb302859510604256fdb81ea1b0d46fb
2021-11-18 16:41:36 +01:00
Wojciech Tyczyński 498feb7a9e Add watchcache metrics to tracking its progress
Kubernetes-commit: ba5e08223d3c199a8efb69248728d41e71d70cd0
2021-11-30 11:12:54 +01:00
Wojciech Tyczyński 71bfcaaea1 Simplify storage.Interface by merging Watch and WatchList functions.
Kubernetes-commit: 53653e9b0a7145c3b6e133c5639194ff79b3719d
2021-11-18 12:40:26 +01:00
Madhav Jivrajani af19f84a96 cacher: refactor process() function
Split process() function into processEvents() and process().
This is done in anticipation of GetAllEventsSinceThreadUnsafe()
returning an entity using which events can be constructed and
not the events itself.

Subsequently, this commit also moves updating resource version
for initEvents from Watch() to the processEvents() func.

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

Kubernetes-commit: aab7cd3d8a66f425022ca5b2a2bd0d3019efe526
2021-10-29 14:41:10 +05:30
Dr. Stefan Schimanski c0ff3feb85 apiserver/watchcache: doc watch event fan-out to blocked watchers better
Kubernetes-commit: 94b2bb1d3dcfe7973329cc56024f449adde4086c
2021-10-08 17:05:27 +02:00
Mike Spreitzer 889106eff7 Add metrics about handling LIST requests
Add metrics that illuminate the costs of handling LIST requests.

Kubernetes-commit: bf424292db185546c474b27b963fd27bdbafc72f
2021-09-01 18:18:23 -04:00
wojtekt b898581360 Migrate to k8s.io/utils/clock in apiserver
Kubernetes-commit: 859a98c0358610e2c127cd2fba1be601ca975188
2021-09-14 20:36:07 +02:00
Abu Kashem bd2ef9810a apf: estimate list width
Kubernetes-commit: 296c18ec323328bf1c6a621a9ca3a094d78bb9d0
2021-06-22 19:38:00 -04:00
Antonio Ojea 42a99cd0a2 decouple timeBudget from real clock
instead of using a goroutine refreshing the budget, obtain
the value from the last time the budget was accessed.

Kubernetes-commit: dd2c38306000eeb1720afc8346165a6caab09259
2021-07-20 13:54:59 +02:00
wojtekt cd8b524e3f Avoid code duplication in watchcache
Kubernetes-commit: 2df05df6982df93e4ced37d1236f0366069d5838
2021-07-07 09:40:58 +02:00
wojtekt 5290a24345 Implement support for watch initialization in P&F
Kubernetes-commit: 0cc217647ca8be0820973b970124a072c27b6575
2021-05-07 12:49:06 +02:00
Maciej Borsz 5d1582cdd6 Print queue lengths on watch termination
Kubernetes-commit: 8f8beeabb7deb04624c70444012ebc8ba59d990f
2021-01-20 09:32:00 +01:00
Maciej Borsz 8313c177f0 Improve logging in cacheWatcher
Kubernetes-commit: b78f0b31063b7d47781a1ce9ee4ed6c118fb949f
2021-01-11 12:33:52 +01:00
Maciej Borsz 255da953aa Add 'apiserver_terminated_watchers_total'
Kubernetes-commit: 342ad48feb2629ebc832c0b85c52b4eb04d81498
2021-01-08 10:55:44 +01:00
wojtekt 3de94d4883 Unify variable naming between GuaranteedUpdate and Delete in storage
Kubernetes-commit: d0726e4b1354b1c8c3978b96ab7b01d13a2b6340
2020-12-16 09:28:44 +01:00
wojtekt ddcc69d4f7 Use current state from watchcache to avoid etcd get for deletions
Kubernetes-commit: 7bab6a9c6ed7d4e54da3e010a7bf0a30786d28f9
2020-11-03 17:30:26 +01:00
wojtekt 8c25869e43 Add suggestion to storage interface Delete method
Kubernetes-commit: c2d61896f45967cdea15072b7a12faeb635b5dc5
2020-11-03 13:21:00 +01:00
chenyw1990 e6daad296e Fix cacheWatcher leak when time jump to the future and jump back
Kubernetes-commit: 36d5db95f8598bc64071c663c6f44a453c662102
2020-11-05 22:02:41 +08:00
wojtekt 942f220e85 Remove variadic argument from storage interface
Kubernetes-commit: 8b98305858b107369f2c9b9fd8ef1c5b0da078c0
2020-11-02 15:52:51 +01:00
wojtekt e0edc885d5 Fix cacher test flakiness
Kubernetes-commit: 6eb71c4089f69c7cc35ef2fd13bba4329b5716b9
2020-10-26 15:29:51 +01:00
wojtekt cdc93483b8 Watch bookmarks may contain version of objects of other types
Kubernetes-commit: 0bd8104809922aae504fc9be2e853650ecd17b8a
2020-09-29 12:27:20 +02:00
wojtekt c4fb001eda Enable progress notify events in watchcache
Kubernetes-commit: a94fb5369d5e77b3fcafd1296bac072a1d6e13fe
2020-08-31 13:15:36 +02:00
Joe Betz 97937c66f2 Revert nested trace PR#88936
Kubernetes-commit: 02cf58102a61b6d1e021e256381ff750573ce55d
2020-07-20 09:55:05 -07:00
Joe Betz 7a467399ac Enable nested tracing, add request filter chain tracing incl. authn/authz tracing
Kubernetes-commit: b12ac0abc64adb71d97fbde12f373b1424631f20
2020-03-06 16:11:21 -08:00
Joe Betz ee219411ed Add ResourceVersionMatch parameter to make Resource Version semantics consistent for list
Kubernetes-commit: e214f2408b59c745c199645547948a8ad2a87ac2
2020-05-29 10:44:26 -07:00
wojtekt 8a4e4b61c9 Add initialization logs to watchcache
Kubernetes-commit: 34b2cf7d2e1c09e10d97ec83e413c41ea7364d80
2020-06-18 13:55:23 +02:00
gongguan 5dbb27a1df remove deprecated cacher CacheCapacity config
Kubernetes-commit: 12c838136b09005e0cbc831096643195ef24cb89
2020-06-05 21:34:36 +08:00
gongguan 1da8aeae17 improve Clock as Cacher Config
Kubernetes-commit: 0f7de876a5e931a57ba6347b81e8e28d360c788a
2020-06-15 23:57:11 +08:00
Wojciech Tyczynski 54e40d4b2d Revert "Revert "Rely on default watch cache capacity and ignore its requested size""
Kubernetes-commit: 7787ebc85b87eb7bc00f234f4e52eed3d987d5dd
2020-05-27 14:19:38 +02:00
Joe Betz 5b75cf0ff9 Add GetOptions and ListOptions to storage interface
Kubernetes-commit: 4c99949ae6b4a74e4ffda0caba86c151c23d579e
2020-05-29 10:48:33 -07:00
Jordan Liggitt d501f7b597 Revert "Rely on default watch cache capacity and ignore its requested size"
This reverts PR 91260

Kubernetes-commit: 6249f287e1d3d9fb63b60961c8625a82d7db360e
2020-05-23 09:21:22 -04:00
wojtekt 31ffec3302 Rely on default watch cache capacity and ignore its requested size
Kubernetes-commit: 99dff90d613e2014873dc2fae0a00acaf95c3bd2
2020-05-19 18:13:28 +02:00
Davanum Srinivas 5879417a28 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
wojtekt 6332f98216 Update duration to be kept in watchcache
Kubernetes-commit: d1de6295bb8047cbfd2a4ecbb0d264197f4cd8a4
2020-05-04 17:21:40 +02:00
Wojciech Tyczynski 4589c74d5e Send watch bookmarks every minute
Kubernetes-commit: 9f1e4620379028754f2da4223adf4d1a445e90f4
2020-04-27 18:41:31 +02:00
Wojciech Tyczynski 7686f3528b Revert "Send watch bookmarks every minute"
Kubernetes-commit: 1cb98ed2376b1f7777ca3d7bfac98cbb5f8b9ce3
2020-04-27 17:07:27 +02:00
wojtekt f1c77ba823 Send watch bookmarks every minute
Kubernetes-commit: d4b532e7190c2ad12a0317ff946e2cd0b33f0ada
2020-04-17 19:42:26 +02:00
louisgong 4c8b97679c Use dynamic size watch-cache.
If all cached events occur inside eventFreshDuration, increase cache capacity by 2x.
Decrease cache capacity by 2x when recent half events occur outside eventFreshDuration.

Kubernetes-commit: 56407b656c7acf6039cead0192070429e53a0c70
2020-04-12 17:22:38 +08:00
louisgong 1117ccdc72 move watchCache metrics to a seperate file
Kubernetes-commit: 21ba510ef0e02f64a813cb460212cb832f8f4d78
2020-04-16 15:45:16 +08:00
shaloulcy 6099d76e39 add indexer for storage cacher
Signed-off-by: shaloulcy <lcy041536@gmail.com>

Kubernetes-commit: 87582e2c3c1cb8c8e10ec05a4700f865c759b7b2
2019-11-19 16:52:07 +08:00
wojtekt a76d249b96 Tweak use of caching objects
Kubernetes-commit: c5170dfb66749b60a4a1611dc7b4a39e64b33e2e
2019-10-16 09:05:13 +02:00
wojtekt b950ddfb46 Promote WatchBookmarks feature to GA
Kubernetes-commit: a22a4ed3c54d6e30edc972f501fbfddc789bea9b
2019-09-26 15:29:52 +02:00
Wojciech Tyczynski 20ecceebd3 Cache serializations
Kubernetes-commit: 25a728ae5eb0ae067d21679fad915c0555242470
2019-08-25 09:55:52 +02:00
Ted Yu 66fb39740e Return proper Kind in error for Cacher
Kubernetes-commit: e4d880bd62fc694bffc188a680c9c088a86a5167
2019-09-07 19:42:56 -07:00
Han Kang 3e6e1db500 add some documentation around the metrics stability migration changes for clarity
Kubernetes-commit: 4e5d906c4d008f914b0ede26ea91533d6343dec5
2019-08-26 19:15:30 -07:00
Han Kang b9084e350a migrate kube-apiserver metrics to stability framework
Kubernetes-commit: 466980dd747e06e55451301c624eecccfa505123
2019-08-22 15:38:42 -07:00
Joe Betz f103fcda51 Replace string concatination with trace fields
Kubernetes-commit: 46a04d50af78e01d06a9879d62cc71fbe892076f
2019-08-02 23:47:24 -07:00
Ted Yu 258e8e3387 Rename cacheWatcher#stop
Kubernetes-commit: 0b3c07a98c7c03e3edcf4f21ff96ea74082a54e5
2019-08-02 04:32:50 -07:00
Ted Yu 2fe1729c24 Refine watcher count calculation
Kubernetes-commit: 4ce92b05acf7fec89c8723ba1779bf9e2baf55f4
2019-07-30 23:04:54 -07:00
Ted Yu 06470a960d Pop expired watchers in case there is no update
Kubernetes-commit: 0204bc7e2594c297f146701132ee969721ada2ab
2019-07-30 06:49:01 -07:00
Ted Yu 4eb89249bd Rename TriggerPublisherFunc as IndexerFunc
Kubernetes-commit: 6e98aab26e4fb867a6d8b4342937823cf1597d89
2019-07-18 06:45:48 -07:00
wojtekt bb8cecbe8c Simplify trigger functions in cacher
Kubernetes-commit: 68fd329e00d1ddf19a7ec0db1607820a1c4c008a
2019-07-04 14:21:06 +02:00
wojtekt fa23498ce7 Propagate error from creating cacher and storage decorators up
Kubernetes-commit: ee13be28845e8c55f6e2a2207ca4f46cd67fdb4e
2019-07-15 09:34:08 +02:00
fansong.cfs ec1dcedb44 delivery event non blocking firstly
Kubernetes-commit: 5e493ab467472f38d7e78b19180bb6c7684170f0
2019-04-28 21:06:59 +08:00
Ted Yu 5f417af526 Clear valueWatchers instead of removing every entry using a loop
Kubernetes-commit: a06daff032f981672a47c71b23c62b9b85793893
2019-07-01 20:11:39 +08:00
Jordan Liggitt 00e2435130 Make GetRemainingItemCount/SetRemainingItemCount use pointers
Kubernetes-commit: 145e8c46cf81ff16b65ff729c392ced262984847
2019-05-27 12:03:26 -04:00
Chao Xu 5c9333e4d3 Run deleteValidation at the storage layer so that it will be retried on
conflict.

Adding unit test verify that deleteValidation is retried.

adding e2e test verifying the webhook can intercept configmap and custom
resource deletion, and the existing object is sent via the
admissionreview.OldObject.

update the admission integration test to verify that the existing object
is passed to the deletion admission webhook as oldObject, in case of an
immediate deletion and in case of an update-on-delete.

Kubernetes-commit: 7bb4a3bace048cb9cd93d0221a7bf7c4accbf6be
2019-04-09 13:49:16 -07:00
Jordan Liggitt fea4dc8e52 Terminate watchers when watch cache is destroyed
Kubernetes-commit: d304c9ecbbd81a32f2c2e059d79e3f79d458a960
2019-05-17 10:02:08 -04:00
Chao Xu 034ed25bbe Add RemainingItemCount to ListMeta
Kubernetes-commit: 58c18309a84f9e0fe05b92c202616e4ecf8062f7
2019-04-01 14:44:19 -07:00
Ted Yu e65e768f58 Use read lock in ready#check
Kubernetes-commit: 04a7b50a020906e8e5cd32dfce378125606ce97d
2019-04-18 14:00:42 -07:00
wojtekt a3fd374f10 Reduce contention in watchcache by not calling event handler under lock
Kubernetes-commit: e6e43828284c6e83cf2b4658fa377b4cc7dec0c3
2019-04-17 12:53:36 +02:00
fansong.cfs d08e2bcfac add object type to cacheWatcher
Kubernetes-commit: 6c6d472039ea3628ac014d38a7ccc516554fce81
2019-04-23 00:35:56 +08:00
fansong.cfs 58fb117373 add watch bookmark
Kubernetes-commit: d70edd3d39d4430d71c4b7c9adba8df5ba7f16c8
2019-03-19 18:16:23 +08:00
wojtekt 22832ea49c Minor cleanup in cacher
Kubernetes-commit: 5d368ff301d328e4ffa5abacb3c2f2aeddb7715a
2019-04-10 12:56:02 +02:00
Wojciech Tyczynski 670ff8c10b Revert "delivery event non blocking firstly"
Kubernetes-commit: cea9d65a2c9add769b4f5c0473a1ba3ae6ce0d8b
2019-04-05 15:36:08 +02:00
fansong.cfs 73057f16b6 add timeout suuport for watch
Kubernetes-commit: b304a1f96d85cd351a0e22a091e17064d5edb35e
2019-04-03 09:37:48 +08:00
Joe Betz 4cc45f82fc Add resourceVersion=0 paginated list integration test for disabled and enabled watch cache
Kubernetes-commit: e5a4f09ab3ac15815ceb039fbc7f546266855fd6
2019-03-21 11:25:07 -07:00
Joe Betz f90442e3fb Paginate List call performed by Reflector's ListAndWatch call
Kubernetes-commit: 84723c2d3ef5ff5d30aadd1ad72068bf2254358c
2019-03-14 13:26:19 -07:00
fansong.cfs c302cc97dd delivery event non blocking firstly
Kubernetes-commit: 8910abfdf3d13faf2bf415dc1019006fb06cbc9f
2019-03-21 17:11:58 +08:00
Benjamin Elder 8ad12b3912 Revert "add timeout suuport for watch"
This reverts commit c676e234cc1036a2a1147f2eeef9c89468671330.

Kubernetes-commit: 30a56bab42ab14a3a2ee21f5581b02525d4fd110
2019-04-01 18:39:17 -07:00
fansong.cfs 4d2b8eee69 add timeout suuport for watch
Kubernetes-commit: c676e234cc1036a2a1147f2eeef9c89468671330
2019-03-30 20:07:41 +08:00
fansong.cfs 9130ee52b5 Refactor watchcache to support bookmark
Kubernetes-commit: b29e69c1562f66cf339ae7cd58979528791f035f
2019-03-29 17:49:15 +08:00
wojtekt 6c2f66a5b5 Add explanation about forgetFunc in cacher
Kubernetes-commit: 605522b0c714c173d0a1ec8d00e46c3629107267
2019-03-27 08:24:45 +01:00
wojtekt 6ef883ed27 Reduce critical sections in watchache
Kubernetes-commit: 010cb4480825b54afb85c9fa97e2edc950a6d185
2019-02-20 10:41:50 +01:00
wojtekt d087fef459 Reduce lock contention in watchcache.
Kubernetes-commit: 9452adc5c89a834cd34a7758089804db0063f316
2019-02-12 14:26:45 +01:00
wojtekt 783162a9d2 Add metric exposing amount of processed init events in watchcache
Kubernetes-commit: 0a0835e92dddf98208e84d3ca5661739b7ebf164
2019-02-04 08:13:44 +01:00
wojtekt d8d5623948 Avoid going back in time in watchcache watchers
Kubernetes-commit: 1b436f1a2f8b735fea722254e09473e0707615dc
2019-02-08 12:30:04 +01:00
wojtekt 19dec1e94f Reduce Pool contention in cacher
Kubernetes-commit: c121632360355ce364f58f0babf20710522d8b0e
2019-02-06 10:44:57 +01:00
Andrew Kim 2b43930b32 replace k8s.io/apiserver/pkg/util/trace with k8s.io/utils/trace
Kubernetes-commit: 93b086f6eafc1e94214fc1d946a1917482751cf3
2019-01-24 11:50:30 -05:00
Jordan Liggitt 80029a760c Deprecate and remove use of alpha metadata.initializers field, remove IncludeUninitialized options
Kubernetes-commit: 17aa60686ebe5fd04b4fe6f442dc36a8d70b6730
2019-01-17 09:19:28 -05:00
wojtekt d0a6ca6003 Use watch cache when rv=0 even when limit is set
Kubernetes-commit: 4242d1b760314adc69498b1f523a4759c446d7c0
2018-11-07 10:38:31 +01:00
Davanum Srinivas 2710b17b80 Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135

Kubernetes-commit: 954996e231074dc7429f7be1256a579bedd8344c
2018-11-09 13:49:10 -05:00
fisherxu 9ffd3e56ff move cacher in separate dir
Kubernetes-commit: dbb448bbdcb9e440eee57024ffa5f1698956a054
2018-05-30 20:44:31 +08:00