151 Commits

Author SHA1 Message Date
Jordan Liggitt
b8c855877f Drop unnecessary gogo dependencies
Kubernetes-commit: 840aa4722e982cfaac5d76735909035d06312c06
2025-09-23 11:34:58 -04:00
Jefftree
8ddf4401e5 Gate apidiscovery/v2beta1 serving with a feature gate
Kubernetes-commit: 95d3d4a22d705ef6bf2d494c065743d356914e8d
2025-03-13 17:58:06 +00:00
novahe
5c7f206b25 Fix test cases that may potentially cause a panic.
Kubernetes-commit: 9e53371ddaaeab4083fde45e43c803071238e686
2025-03-11 17:41:37 +08:00
xin.li
d8b34c3ab2 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
Sascha Grunert
be40e97e1a Replace github.com/golang/protobuf with google.golang.org/protobuf
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>

Kubernetes-commit: c1d0e870f4f45548c0d5b2bf83f36fb208252978
2024-11-07 12:47:08 +01:00
Patrick Ohly
70a4950f35 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
Matthieu MOREL
9d7f486102 fix: enable expected-actual rule from testifylint in module k8s.io/client-go
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Kubernetes-commit: 8286a69034d58e1ceafd6a6e5590bfcebd920b5b
2024-09-27 07:48:55 +02:00
Matthieu MOREL
290f054d9b fix: enable compares rule from testifylint in module
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Kubernetes-commit: 407d74fb6a563951045287338a6c64a79fcad8ec
2024-09-21 21:23:07 +02:00
Matthieu MOREL
acc5917341 fix: enable empty and len rules from testifylint on pkg package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>

Kubernetes-commit: f014b754fb5925dfbca6e27a44d0c3968b157e14
2024-06-28 21:20:13 +02:00
Feilian Xie
c45bc431c3 Return the error returned by Invokes so the FakeDiscovery client is able to simulate any error with reactors.
Signed-off-by: Feilian Xie <fxie@redhat.com>

Kubernetes-commit: 33557a2f6c82d10fa6a459d2ebac56d6a2670492
2024-07-04 17:29:57 +08:00
Jefftree
4bf7f9496e Use v2 types with agg discovery
Kubernetes-commit: 462dd326c2e98d937a96d49002883000efe4b2d6
2024-01-19 16:13:47 -05:00
Tim Hockin
7087b65a74 Cleanup: s/depreciated/deprecated/g
Kubernetes-commit: 9f4b82bf3b079fe868effbd2498b61464db6d459
2024-02-18 14:50:55 -08:00
Tarun Gupta Akirala
5a38750180 fix: add code comments
Kubernetes-commit: 1863a808b2082ddd8d116e6b31fd41de412e8a20
2023-08-10 10:50:01 -07:00
Tarun Gupta Akirala
f93655277b client-go: chore: implement Is interface for ErrGroupDiscoveryFailed
Signed-off-by: Tarun Gupta Akirala <takirala@users.noreply.github.com>

Kubernetes-commit: 6aad00ff73d10378d33d615505239c5373a1108b
2023-08-07 12:08:09 -07:00
Paco Xu
92c5c93353 remove GAed FG GRPCContainerProbe
Kubernetes-commit: 7e7b67f2ccd38380120b6da2ccb10ae74970a7a6
2023-08-30 10:29:37 +08:00
Jefftree
f02c594955 Cleanup kubectl legacy server fallback
Kubernetes-commit: d1946392528fe6e26886810e8240568fa19e82fe
2023-07-18 18:24:56 +00:00
Jefftree
c4ed5da76e Fallback to legacy discovery on a wider range of conditions in aggregator
Kubernetes-commit: 57b27fd3cd11cb5f2515c7ac5f67f612998fb368
2023-08-09 18:22:30 +00:00
Jordan Liggitt
daed746fdc Add GroupDiscoveryFailedErrorGroups helper method
Kubernetes-commit: 733f63c6c423565b8cecf3f3db8e9d81e48b1311
2023-05-15 09:23:54 -04:00
Jordan Liggitt
bf44ac9180 Avoid returning nil responseKind in v1beta1 aggregated discovery
Kubernetes-commit: 1876ddf71497bad349f7c4df24c2e22356d3bad9
2023-08-08 14:25:56 -04:00
Jefftree
2bd3f49236 Update gnostic references
Kubernetes-commit: 2111e79f56acdfa6a8dab56780c52e3abc608758
2023-06-01 18:25:39 +00:00
Sean Sullivan
5c4e72cc66 Refactors discovery content-type and helper functions
Kubernetes-commit: 2af662b05fe591083a029520e6da5b077cad8e31
2023-04-24 17:40:07 -07:00
Tim Hockin
12553015e2 Replace uses of ObjectReflectDiff with cmp.Diff
ObjectReflectDiff is already a shim over cmp.Diff, so no actual output
or behavior changes

Kubernetes-commit: bc302fa4144d21a338683cd83701661f97be4aba
2023-03-23 11:34:03 -07:00
Sean Sullivan
2bd557faec Aggregated discovery resilient to nil GVK
Kubernetes-commit: 26bf8a7ceb51bac357d8a02fd3e62b84363716db
2023-03-14 17:59:19 +00:00
Tim Allclair
b8c2b4bd8c Fix broken API docs URLs
Kubernetes-commit: ea974280dc9948e31d426ee6366abff0957a5f82
2023-03-10 19:18:06 -08:00
Jefftree
eec00dc791 remove mime AddExtensionType in discovery test
Kubernetes-commit: 50c6b6c86a50d0196af4bc659948d8dfd2147308
2022-12-05 17:30:08 +00:00
Sean Sullivan
6b8e57ec24 Plumb stale GroupVersions through aggregated discovery
Kubernetes-commit: fed7bb7c51e9f85db122ad6d111cb8326dce9f8a
2023-02-28 19:44:34 +00:00
Sean Sullivan
0bc91705fa Tolerate empty discovery response in memcache client
Kubernetes-commit: a49f13258548c71194e3001ebf5fa219b88155d0
2023-02-22 23:59:37 +00:00
Sean Sullivan
bc1864f6cf Removes old discovery hack ignoring 403 and 404
Kubernetes-commit: 298cb361c85be02d6336437bde37c8a4ccf5583a
2023-02-17 12:47:05 -08:00
Paco Xu
20ca706950 cleanup: EphemeralContainers feature gate related codes
Kubernetes-commit: 70e56fa71af5aa4f3d1448fcbc26e86309cd0cf3
2022-12-16 23:46:47 +08:00
Max Horstmann
24248303bf client-go: properly return error in fake discovery (#79612)
Fake discovery should return an error if an error-returning reactor was prepended.

This is relevant e.g. for unit tests which test a function which relies
on discovery to check if an API Server is available.

Matches existing behavior of other fake types, for example fake_namespace.

Adds unit test coverage as well.

Kubernetes-commit: b47748103a53c0fe5ba1ddc950662ffc9bd9ed0f
2022-12-14 11:41:10 -05:00
Abhijit Hoskeri
4dbb1cd1d5 Check the correct error in d.downloadAPIs
The error result of `d.downloadAPIs()` is set in `aerr`,
not `err`.

This prevents a nil-ptr dereference of apiGroups in the next step.

Signed-off-by: Abhijit Hoskeri <abhijithoskeri@gmail.com>

Kubernetes-commit: 450ba4f50638ad9ee4d287a762a8530c64e89ebd
2022-12-10 16:32:02 -08:00
Sean Sullivan
3ac73ea2c8 Adds bool to force non-aggregated discovery
Kubernetes-commit: a84d877310ba5cf9237c8e8e3218229c202d3a1e
2022-11-09 12:30:05 -08:00
Sean Sullivan
25d5761bfa Aggregated discovery client
Kubernetes-commit: b8fe2c7b8061e6ab0b093a49351bac256606da4a
2022-11-03 11:09:58 -07:00
Alexander Zielenski
624929cd3f address feedback
Kubernetes-commit: 32d834a88673614080bc37727f8cc94b9b85bc86
2022-10-17 10:51:27 -07:00
Alexander Zielenski
12cafe2b1b refactor to use Schema(contentType)
Kubernetes-commit: e6e6dd826d76a2b19515cd907062f1f74f9e52c2
2022-10-14 12:46:36 -07:00
Alexander Zielenski
8b6ceae557 add more options for fetching openapiv3 in clients
remove serialized types from client

update tests

Kubernetes-commit: fec79e75a50f334d8384a5377513fc78222ea36a
2022-10-12 11:43:46 -07:00
inosato
27de641f75 Remove ioutil from client-go
Signed-off-by: inosato <si17_21@yahoo.co.jp>

Kubernetes-commit: 88dfa51b6003c90e8f0a0508939a1d79950a40df
2022-07-30 20:54:41 +09:00
Nic Cope
761f55c9e0 Use SHA256 sums to verify discovery cache integrity
This is a little more computationally expensive but reduces the
likelihood of a potentially malicious cache collision.

Signed-off-by: Nic Cope <nicc@rk0n.org>

Kubernetes-commit: c5957c284e1d23bdadc98fbbe2bb481fc1f345d4
2022-07-26 23:51:01 -07:00
Nic Cope
735524f850 Use sha256 to sanitize discovery HTTP cache keys
This helps avoid (potentially malicious) collisions when reading and
writing cache data.

Signed-off-by: Nic Cope <nicc@rk0n.org>

Kubernetes-commit: 288a17fd337c65cb5aea44e44ecb74e9cb8088f5
2022-07-14 14:11:33 -07:00
Nic Cope
1ea239faa5 Use checksums instead of fsyncs to manage discovery cache corruption
Part of the API discovery cache uses an HTTP RoundTripper that
transparently caches responses to disk. The upstream implementation of
the disk cache is hard coded to call Sync() on every file it writes.
This has noticably poor performance on modern Macs, which ask their disk
controllers to flush all the way to persistant storage because Go uses
the `F_FULLFSYNC` fnctl. Apple recommends minimizing this behaviour in
order to avoid degrading performance and increasing disk wear.

The content of the discovery cache is not critical; it is indeed just a
cache and can be recreated by hitting the API servers' discovery
endpoints. This commit replaces upstream httpcache's diskcache
implementation with a similar implementation that can use CRC-32
checksums to detect corrupted cache entries at read-time. When such an
entry is detected (e.g. because it was only partially flushed to
permanent storage before the host lost power) the cache will report a
miss. This causes httpcache to fall back to its underlying HTTP
transport (i.e. the real API server) and re-cache the resulting value.

Apart from adding CRC-32 checksums and avoiding calling fsync this
implementation differs from upstream httpcache's diskcache package in
that it uses FNV-32a hashes rather than MD5 hashes of cache keys in
order to generate filenames.

Signed-off-by: Nic Cope <nicc@rk0n.org>

Kubernetes-commit: 7a2c6a432f9e8db8b84abe5607843429f8bff417
2022-06-28 19:15:49 -07:00
Nic Cope
76fccca0ea Add a benchmark for the discovery cache RoundTripper
This benchmark is intended to demonstrate a performance improvement
gained by removing fsyncs. Refer to the below issue for more detail.

https://github.com/kubernetes/kubernetes/issues/110753

Signed-off-by: Nic Cope <nicc@rk0n.org>

Kubernetes-commit: eace46906512b99c23ad9635edc2ea055363a602
2022-06-28 19:40:58 -07:00
Alper Rifat Ulucinar
4aac6a7c9c Bump discovery burst of default ConfigFlags to 300
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>

Kubernetes-commit: 45f653e3db6a120d7cafaf2a9262fb3c8a2e22a2
2022-07-14 09:58:55 +03:00
Alper Rifat Ulucinar
ed7d154cc2 Bump default burst limit for discovery client to 300
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>

Kubernetes-commit: 534427f5d3134189f49e6811a7642b86cf92c55a
2022-03-30 11:19:41 +03:00
HaoJie Liu
2f582c2a40 Fix:import the same package multiple times
Signed-off-by: HaoJie Liu <liuhaojie@beyondcent.com>

Kubernetes-commit: 4f0a0ec81c649727cfc62cf8c0a2ad7eabf12516
2022-07-12 17:41:37 +08:00
Alexander Zielenski
fa08fc21f5 adjust comments
Kubernetes-commit: e9fc6c28a202ded0228e8505f5e14f5ec2049a3d
2022-03-28 18:40:34 -07:00
Alexander Zielenski
018cf8ace6 add fetching into discovery client for OpenAPI v3
reflect latest struct changes

use correct discovery openapi test data layout

make the OpenAPIv3 interface less blue

field grouping

add copyrights

implement cached discovery client

add cached discovery tests

address review feedback

Kubernetes-commit: 075866b3e3ea029c243d82d8d6eb99e96d9c49d3
2022-03-22 10:40:56 -07:00
Arda Güçlü
7e062f8fa4 Remove deprecated discovery/ServerResources function
ServerResources function was deprecated and instead ServerGroupsAndResources
function is suggested.

This PR removes ServerResources function and move every place to use ServerGroupsAndResources.

Kubernetes-commit: ef39a8914291ba200bd5486c88a7575ffd4b7d1d
2021-12-22 11:14:09 +03:00
Jefftree
186c332c7b googleapis/gnostic -> google/gnostic
Kubernetes-commit: 8a1d5947ad34ba275192341baa4e5fef8e6c7f24
2022-03-15 20:36:21 -07:00
David Eads
7d7fd497a0 add resource enablement check for e2e tests of beta APIs
Kubernetes-commit: 8ab8d05cc40c391f8ac650f50f23500666bfc943
2022-03-01 11:51:16 -05:00
Antonio Ojea
5b8ad0da8e migrate nolint coments to golangci-lint
Kubernetes-commit: d126b1483840b5ea7c0891d3e7a693bd50fae7f8
2021-11-16 16:57:58 +01:00