Commit Graph

3197 Commits

Author SHA1 Message Date
Mike Danese 0326ed9810 migrate token cache to cache.Expiring
Kubernetes-commit: 3f194d5b413daeba93063f4610b9951069eaf13c
2019-11-06 16:23:21 -08:00
Mike Danese dadb023ccc Add an expiring cache for the caching token authenticator
And maybe the webhook authorizer cache.

This cache has two primary advantages over the LRU cache used currently:

- Cache hits don't acquire an exclusive lock.
- More importantly, performance doesn't fallover when the access pattern
  scans a key space larger than an arbitrary size (e.g. the LRU
  capacity).

The downside of using an expiring cache here is that it doesn't have a
maximum size so it's suspectible to DoS when the input is user
controlled. This is not the case for successful authentications, and
successful authentications have a natural expiry so it might be a good
fit here.

It has some a few differences compared to:

3d7318f29d/staging/src/k8s.io/client-go/tools/cache/expiration_cache.go

- Expiration is not entirely lazy so keys that are never accessed again
  are still released from the cache.
- It does not acquire an exclusive lock on cache hits.
- It supports per entry ttls specified on Set.

The expiring cache (without striping) does somewhere in between the
simple cache and striped cache in the very contrived contention test
where every iteration acquires a write lock:

```
$ benchstat simple.log expiring.log
name      old time/op    new time/op    delta
Cache-12    2.74µs ± 2%    2.02µs ± 3%  -26.37%  (p=0.000 n=9+9)
name      old alloc/op   new alloc/op   delta
Cache-12      182B ± 0%      107B ± 4%  -41.21%  (p=0.000 n=8+9)
name      old allocs/op  new allocs/op  delta
Cache-12      5.00 ± 0%      2.00 ± 0%  -60.00%  (p=0.000 n=10+10)

$ benchstat striped.log expiring.log
name      old time/op    new time/op    delta
Cache-12    1.58µs ± 5%    2.02µs ± 3%  +27.34%  (p=0.000 n=10+9)
name      old alloc/op   new alloc/op   delta
Cache-12      288B ± 0%      107B ± 4%  -62.85%  (p=0.000 n=10+9)
name      old allocs/op  new allocs/op  delta
Cache-12      9.00 ± 0%      2.00 ± 0%  -77.78%  (p=0.000 n=10+10)

$ benchstat simple.log striped.log expiring.log
name \ time/op    simple.log   striped.log  expiring.log
Cache-12          2.74µs ± 2%  1.58µs ± 5%   2.02µs ± 3%
name \ alloc/op   simple.log   striped.log  expiring.log
Cache-12            182B ± 0%    288B ± 0%     107B ± 4%
name \ allocs/op  simple.log   striped.log  expiring.log
Cache-12            5.00 ± 0%    9.00 ± 0%     2.00 ± 0%
```

I also naively replacemed the LRU cache with the expiring cache in the
more realisitc CachedTokenAuthenticator benchmarks:

https://gist.github.com/mikedanese/41192b6eb62106c0758a4f4885bdad53

For token counts that fit in the LRU, expiring cache does better because
it does not require acquiring an exclusive lock for cache hits.

For token counts that exceed the size of the LRU, the LRU has a massive
performance drop off. The LRU cache is around 5x slower (with lookups
taking 1 milisecond and throttled to max 40 lookups in flight).

```
$ benchstat before.log after.log
name                                                  old time/op    new time/op    delta
CachedTokenAuthenticator/tokens=100_threads=256-12      3.60µs ±22%    1.08µs ± 4%  -69.91%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=500_threads=256-12      3.94µs ±19%    1.20µs ± 3%  -69.57%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=2500_threads=256-12     3.07µs ± 6%    1.17µs ± 1%  -61.87%  (p=0.000 n=9+10)
CachedTokenAuthenticator/tokens=12500_threads=256-12    3.16µs ±17%    1.38µs ± 1%  -56.23%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=62500_threads=256-12    15.0µs ± 1%     2.9µs ± 3%  -80.71%  (p=0.000 n=10+10)

name                                                  old alloc/op   new alloc/op   delta
CachedTokenAuthenticator/tokens=100_threads=256-12        337B ± 1%      300B ± 0%  -11.06%  (p=0.000 n=10+8)
CachedTokenAuthenticator/tokens=500_threads=256-12        307B ± 1%      304B ± 0%   -0.96%  (p=0.000 n=9+10)
CachedTokenAuthenticator/tokens=2500_threads=256-12       337B ± 1%      304B ± 0%   -9.79%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=12500_threads=256-12      343B ± 1%      276B ± 0%  -19.58%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=62500_threads=256-12      493B ± 0%      334B ± 0%  -32.12%  (p=0.000 n=10+10)

name                                                  old allocs/op  new allocs/op  delta
CachedTokenAuthenticator/tokens=100_threads=256-12        13.0 ± 0%      11.0 ± 0%  -15.38%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=500_threads=256-12        12.0 ± 0%      11.0 ± 0%   -8.33%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=2500_threads=256-12       13.0 ± 0%      11.0 ± 0%  -15.38%  (p=0.000 n=10+10)
CachedTokenAuthenticator/tokens=12500_threads=256-12      13.0 ± 0%      10.0 ± 0%  -23.08%  (p=0.000 n=9+10)
CachedTokenAuthenticator/tokens=62500_threads=256-12      17.0 ± 0%      12.0 ± 0%  -29.41%  (p=0.000 n=10+10)
```

Benchmarked with changes in #84423

Bugs: #83259 #83375

Kubernetes-commit: 9167711fd18511ffc9c90ee306c462be9fc7999b
2019-10-26 12:19:07 -07:00
Kubernetes Publisher a0a37e0a76 Merge pull request #85257 from yutedz/queueset-robin-idx
Correct the checking of robinIndex

Kubernetes-commit: 8dffc8db4fbb2004dd379bd47833d0a55d11cbb5
2019-11-15 02:02:17 +00:00
Kubernetes Publisher 6b2c200efa Merge pull request #84304 from liggitt/all-beta
Add support for --runtime-config=api/beta=false, --feature-gates=AllBeta=false

Kubernetes-commit: f1e912c38abcecfb64e36eb161128b15e69a135b
2019-11-15 02:02:14 +00:00
Kubernetes Publisher 387bf36109 Merge pull request #85175 from liggitt/golang-org-comments
Add comments to explain golang.org replace directives

Kubernetes-commit: 24334444b46371e26594e1f6e594195a761b53d3
2019-11-14 22:14:35 +00:00
Kubernetes Publisher 6b85cf0e72 Merge pull request #85227 from apelisse/update-smd
Update structured-merge-diff to latest version

Kubernetes-commit: 85bc79d81f506bfdca26bbafeab5f43efe88f08f
2019-11-14 10:26:29 +00:00
Kubernetes Publisher 6070034623 Merge pull request #85192 from MikeSpreitzer/fq-impl
Added fair queuing for server requests

Kubernetes-commit: 022120ccac47470de9055d756b766814cc030a38
2019-11-14 10:26:27 +00:00
Kubernetes Publisher 5ec070f50a Merge pull request #85152 from mikedanese/tokbench
report cache misses in cached token authenticator benchmark

Kubernetes-commit: 570572b38773829e2841033967f7f7364f56206e
2019-11-14 10:26:25 +00:00
Kubernetes Publisher acb34b1bc7 Merge pull request #85004 from deads2k/dynamic-agg-cert
dynamic reload cluster authentication info for aggregated API servers

Kubernetes-commit: 02af1dd62c4842e20e2ee7337edf032327b1c8ed
2019-11-14 10:26:24 +00:00
Kubernetes Publisher e5d6ff07be Merge pull request #85138 from liggitt/webhook-config-v1
Promote apiserver.config.k8s.io/v1, kind=WebhookAdmissionConfiguration

Kubernetes-commit: f501d8e59a599eaad45a50ee1da075cedc9d0ab9
2019-11-14 10:26:22 +00:00
Kubernetes Publisher 58a8d30b19 Merge pull request #85098 from liggitt/admission-config-v1
Promote apiserver.config.k8s.io/v1, kind=AdmissionConfiguration

Kubernetes-commit: b49afbfa64b6be72779b6deb424d7f0cddd5ccf1
2019-11-14 10:26:21 +00:00
Kubernetes Publisher 926316189b Merge pull request #84718 from yastij/remove-validators
remove system validators package from kubeadm and use k8s.io/system-validators

Kubernetes-commit: ea2750eaa6f54e240172a44c8c968fa2d926cd41
2019-11-14 10:26:19 +00:00
Kubernetes Publisher 47ab678f7f Merge pull request #84813 from deads2k/admission-feature-gates
remove global variable dependency from admission plugins

Kubernetes-commit: 94efa988f403a9f7d1f0c0287673022d6cb3d2c1
2019-11-14 10:26:17 +00:00
Kubernetes Publisher a3ef59b336 Merge pull request #85135 from wojtek-t/delete_unnecessary_conversions_1
Eliminate couple unnecessary conversions

Kubernetes-commit: 402e551ca27499a9dc211dd6e4eca21d9aa9d089
2019-11-14 10:26:16 +00:00
Kubernetes Publisher ed17cc3738 Merge pull request #84768 from liggitt/delegated-authnz-v1
switch delegated authnz to v1 APIs

Kubernetes-commit: 681d22428b2e037163ea11c13a4c066c2058e515
2019-11-14 10:26:14 +00:00
Kubernetes Publisher 66e4e09007 Merge pull request #84423 from mikedanese/tokbench
adjust token cache benchmarks to get more accurate behavior

Kubernetes-commit: 0708eb5903d664f457f9b5fcd02bb0bae303df68
2019-11-14 10:26:12 +00:00
Ted Yu 82980a5db1 Correct the checking of robinIndex
Kubernetes-commit: 2bdd379a1eb9d0344df41fff0339123849682e7c
2019-11-13 20:13:29 -08:00
Mike Spreitzer cd34d8d0ce Fixed lint and staticcheck oversights
Kubernetes-commit: e10acc78dee5d90d93fc7bc0e76e97bc7bc0b3a3
2019-11-13 09:20:00 -05:00
MikeSpreitzer f3604043e9 Added overlooked BUILD files
Kubernetes-commit: 8c2807319d3818097f3f37ef534285ea32764c90
2019-11-13 09:46:44 +00:00
Mike Spreitzer 63ad2ccdad Brushing up queueset
(1) Replaced random-looking assortment of counter increments and
decrements with something hopefully more principalled-looking.  Most
importantly, introduced the MutablePromise abstraction to neatly wrap
up the complicated business of unioning multiple sources of
unblocking.

(2) Improved debug logging.

(3) Somewhat more interesting test cases, and a bug fix wrt round
robin index.

Kubernetes-commit: 1c31b2bdc65377f502c2306dbdf32a802eb1afb7
2019-11-13 01:52:05 -05:00
Jordan Liggitt 7f4a2d31aa Add comments to explain golang.org replace directives
Kubernetes-commit: 9f40e19d7ac9e2203c23814701468a26eee1964f
2019-11-12 23:54:26 -05:00
Mike Danese d8f26fe9f3 report cache mises in cached token authenticator benchmark
Kubernetes-commit: c5bfea65b9b45c01a09dfefeedffd13b8927140a
2019-11-12 12:40:19 -08:00
Aaron Prindle e231e56df2 review changes - *Locked updates
Kubernetes-commit: 6619df1798859d49bbb52b1c029533035384824e
2019-11-12 09:24:56 -08:00
Aaron Prindle 572fbfc84d review changes
Kubernetes-commit: 396e2d4aa33bb7289cd8e7466e4465f56a73b7d0
2019-11-12 08:51:49 -08:00
Jordan Liggitt b858bded65 Promote WebhookAdmissionConfiguration to v1
Kubernetes-commit: 71fad812caf6be07be3c5eabe9fdc39c29f7b2a9
2019-11-12 09:43:35 -05:00
wojtekt ca6e794c60 Eliminate couple unnecessary conversions
Kubernetes-commit: 067d173266303c5c9a4281e962d3662c34a78053
2019-11-12 14:19:14 +01:00
Jordan Liggitt 4b9c976f43 AdmissionConfiguration v1
Kubernetes-commit: 1234290adfa11eb3dd34242c296e1f1dbe211c19
2019-11-11 11:57:29 -05:00
Kubernetes Publisher 707298a79a Merge pull request #84692 from smarterclayton/protocol_errors
Fix watch negotiation when using a non-default mime type in the client

Kubernetes-commit: c28921f248a8e6c923096154c6e87efcc188b9f0
2019-11-11 06:20:45 +00:00
Antoine Pelisse bab2370cac Update structured-merge-diff to latest version
Kubernetes-commit: 4f0346530d3e228db20aca6bb484d3ed3c83e33b
2019-11-06 09:53:38 -08:00
David Eads 331894196f add featuregate inspection as admission plugin initializer
Kubernetes-commit: 675c2fb924e82091f7ce4601e48daf4cc7030e72
2019-11-05 14:28:40 -05:00
Jordan Liggitt 41ba987d53 generated
Kubernetes-commit: 7349a824df6487d98903fa71cf2fde9e588ba19f
2019-11-04 23:30:34 -05:00
Jordan Liggitt 52b3bfb8fa Switch kubelet/aggregated API servers to use v1 subjectaccessreviews
Kubernetes-commit: d54a70db5cfc0887e2f5177b0c3f795947be6eb4
2019-11-04 23:29:56 -05:00
Jordan Liggitt 086ad4b0b9 Switch kubelet/aggregated API servers to use v1 tokenreviews
Kubernetes-commit: 5ef4fe959a45e423d2b992e9c21e6e9db4b950c5
2019-11-04 22:41:32 -05:00
David Eads 0de0bb0422 dynamic reload cluster authentication info for aggregated API servers
Kubernetes-commit: 3aede35b3b042e8a626e8fb9e1e181e73cd29d0a
2019-11-04 13:46:28 -05:00
David Eads 79c6550889 allow individual ca bundles to be empty in union
Kubernetes-commit: 758f2ce44f82d68a1a67765823179c3f743e199d
2019-11-12 12:44:53 -05:00
Yassine TIJANI 76bb66f0e4 remove system validators package from kubeadm and use k8s.io/system-validators instead
Signed-off-by: Yassine TIJANI <ytijani@vmware.com>

Kubernetes-commit: b9fe59c93e9a2e7808606a180bc35ce574517473
2019-11-04 13:24:59 +01:00
Clayton Coleman 26a8fb1b92 test: Watch should fail immediately on negotiate errors
Instead of returning an error on the watch stream, if we can't properly
negotiate a watch serialization format we should error and return that
error to the client.

Kubernetes-commit: 9aad6aa54d824ba93a6670cd5a0cab6ad337e9f0
2019-11-03 15:08:22 -05:00
Kubernetes Publisher 687a3dde5a Merge pull request #84727 from danwinship/ipv6-bind
fix apiserver to advertise IPv6 endpoints if bound to IPv6

Kubernetes-commit: 49a9b6cadfe6f27045e9ef05179b0af1cb6e9693
2019-11-09 10:40:11 +00:00
Kubernetes Publisher f2672160bd Merge pull request #83840 from liggitt/json-iter
bump json-iterator dependency

Kubernetes-commit: 3387d6cfc73235fd554e5039b85abb7700eaf126
2019-11-09 10:40:08 +00:00
Kubernetes Publisher 8a300abf72 Merge pull request #84963 from liggitt/feature-json-codes
Fix json patch limit check

Kubernetes-commit: 15f586a6c18d7ccbc01f7a1e908dbabcfd146ae2
2019-11-08 19:05:34 +00:00
Kubernetes Publisher 918776919c Merge pull request #84911 from yue9944882/chore/bump-kube-openapi
Pin kube-openapi vendor to 30be4d16710a

Kubernetes-commit: dd6faa5da791c06fa23ff668e4463c3ad2b23340
2019-11-08 07:09:17 +00:00
Kubernetes Publisher 730448e49a Merge pull request #84864 from deads2k/optional-verify-opts
allow a verifyoptionsfunc to indicate that no certpool is available

Kubernetes-commit: 9dfcc369b48f3aae5cd0d2bd0d4c7b9061ed0b0c
2019-11-08 03:05:37 +00:00
Kubernetes Publisher ef4b4944cc Merge pull request #84693 from yutedz/watching-stop
Stop Watching when there is encoding error

Kubernetes-commit: 7c7ae977d5ccc011dc2e1fcb7f06c3da2da09991
2019-11-08 03:05:36 +00:00
Ted Yu 48d357e235 Stop Watching when there is encoding error
Kubernetes-commit: 639af77d463a4d07bc5d7d19366bd98310b55724
2019-11-07 14:32:47 -08:00
Kubernetes Publisher 4dc6b26d2d Merge pull request #84860 from wojtek-t/remove_conversion_funcs_4
Eliminate couple default conversions

Kubernetes-commit: f7c3fa8324e8167aa29df59602ca6e43c55ff2be
2019-11-07 19:08:58 +00:00
attlee-wang 6c2628ccd6 json unmarshal coded error at function applyJSPatch()
Kubernetes-commit: 1da2d00935942a887205f801d4b2acfa227055d2
2019-11-07 20:40:28 +08:00
yue9944882 1d293beddb update k8s.io/kube-openapi to 30be4d16710a
Kubernetes-commit: 8e7606f32898b294fc25152ff8bd34f62d6221d3
2019-11-07 18:39:08 +08:00
Kubernetes Publisher 60260b106f Merge pull request #83520 from jpbetz/reflector-relist-rv
Avoid going back in time in Reflector relist (revived)

Kubernetes-commit: 8ed2f4775a0d2b13c4be790cdfc1f34bc8b6522b
2019-11-07 03:14:16 +00:00
Kubernetes Publisher 1ff272f3f7 Merge pull request #82809 from liggitt/go-1.13-no-modules
update to use go1.13.4

Kubernetes-commit: 695c3061dd92a6b6950f8adf0341ceb4a8dd44d7
2019-11-07 03:14:14 +00:00
David Eads 80b16c1ce7 allow a verifyoptionsfunc to indicate that no certpool is available
Kubernetes-commit: c672affad176c22da66c7ac17cc8805f08533ce9
2019-11-06 10:38:45 -05:00