Commit Graph

210 Commits

Author SHA1 Message Date
aimuz
39f724a06e cleanup: duplicate request_test TestRequestAbsPathPreservesTrailingSlash
Signed-off-by: aimuz <mr.imuz@gmail.com>

Kubernetes-commit: 7da7468a3fc3f914c7b032c25c3e35097fd85449
2023-05-15 23:14:30 +08:00
Michal Fojtik
0cde78477a client-go: add DNS resolver latency metrics (#115357)
* client-go: add DNS resolver latency metrics

* client-go: add locking to DNS latency metrics

* client-go: add locking for whole DNSStart and DNSDone

Signed-off-by: Vu Dinh <vudinh@outlook.com>

* Fix a mismatched ctx on the request

Signed-off-by: Vu Dinh <vudinh@outlook.com>

* Clean up request code and fix comments

Signed-off-by: Vu Dinh <vudinh@outlook.com>

---------

Signed-off-by: Vu Dinh <vudinh@outlook.com>
Co-authored-by: Vu Dinh <vudinh@outlook.com>

Kubernetes-commit: 1c7e87cff27aa009488a9d55342220e223d5c146
2023-06-28 22:56:45 +02:00
Timo Furrer
d11d5308d6 Export DefaultServerUrlFor utility function
Signed-off-by: Timo Furrer <tuxtimo@gmail.com>

Kubernetes-commit: ebaf49dbd709a94e0c44aa75b4c32b50898a05e3
2023-05-16 19:20:07 +02:00
HirazawaUi
84dc0417b2 fix fd leaks and failed file removing for pkg client-go
Kubernetes-commit: 73aeed8766c2c42a6cb4fc8632b1b974f4508dde
2023-05-03 01:35:16 +08:00
Chris Bandy
18ffb5c67f Replace os.Setenv with testing.T.Setenv in tests
T.Setenv ensures that the environment is returned to its prior state
when the test ends. It also panics when called from a parallel test to
prevent racy test interdependencies.

Kubernetes-commit: 89467ad3e9b051515fa9632a7373d6ef01723256
2023-04-15 10:09:47 -05:00
Stephen Kitt
20433f9965 api-machinery: replace intstr.FromInt with intstr.FromInt32
This touches cases where FromInt() is used on numeric constants, or
values which are already int32s, or int variables which are defined
close by and can be changed to int32s with little impact.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 94410ee8078971b8894e5c400ce3fc79f02bc510
2023-03-14 16:17:48 +01: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
Stephen Kitt
22e2a9b6b1 client-go: add an Error() function on Request
Requests can accumulate errors with no obvious indication, e.g. if
their primary purpose is to construct a URL: URL() itself doesn't
return an error if r.err is non-nil.

Instead of changing URL() to return an error, which has quite a large
impact, add an Error() function and indicate on URL() that it should
be checked.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: f69c1c47463ff70ad61adf6f38c4d5b7373e9d0a
2023-02-10 14:44:07 +01:00
Abu Kashem
d2388d199c client-go: add metric to count retries
Kubernetes-commit: b6c369f5c90bbef8058b3d44949f4e815dd6607f
2022-02-28 12:22:09 -05:00
Abu Kashem
67f1485c1d client-go: add unit test for Request thread safety
Kubernetes-commit: ca492a9b62a586caf3e3cd22bc020108a63fb395
2022-08-26 13:24:36 -04:00
Abu Kashem
79c4b4060a client-go: add test to document retry conditions
Kubernetes-commit: 68c542d52246b0b750e332616884350164018695
2022-05-27 09:13:30 -04:00
wongearl
5d95f80033 diff.ObjectReflectDiff is DEPRECATED use cmp.Diff
Kubernetes-commit: 6da08775f9fc8d70f867435f55cf712d3a6ef056
2022-11-02 17:40:19 +08:00
Jordan Liggitt
422fe1f61e Fix indentation/spacing in comments to render correctly in godoc
Kubernetes-commit: 78cb3862f11225135afdf76f3424e2d7b33104c7
2022-12-17 17:31:05 -05:00
Jordan Liggitt
e2f402cda3 Limit request retrying to []byte request bodies
Kubernetes-commit: 69fad419a7666ac416307de4c3ee88c7e61b94db
2022-11-15 17:47:35 -05:00
Sean Sullivan
8ff4970e81 Get response content-type
Kubernetes-commit: 4ca128d71aa94653927b0e529b746cb7428563b1
2022-11-02 00:03:24 +00:00
Antonio Ojea
1bd914a925 client-go: test transport generation is goroutine safe
Kubernetes-commit: fe41181c3d470207772d3ac9a91d4ef2c2a6720d
2022-09-04 12:36:01 +02:00
Vatsal Parekh
bf2b395a89 Fix Infelicities in TestRESTClientLimiter
Signed-off-by: Vatsal Parekh <vatsalparekh@outlook.com>

Kubernetes-commit: c980cf489eeb39fd0fe0af7e80cfea2dbe2007db
2022-09-15 19:30:40 +05:30
Monis Khan
5dab9a0b84 client-go/transport: drop Dial and GetCert fields in favor of Holders
Signed-off-by: Monis Khan <mok@microsoft.com>

Kubernetes-commit: 3313a70d5bcc40a39f99f482c18effc9de6072ba
2022-09-09 08:06:01 -04:00
Shyam Jeedigunta
b8a8d94944 Add DisableCompression option to KubeConfig
Kubernetes-commit: 641fd5b482c6117d459a22d99f76aae086c3524f
2022-09-07 18:04:17 -07:00
cndoit18
bcd2e6c7da style: remove redundant judgment
Signed-off-by: cndoit18 <cndoit18@outlook.com>

Kubernetes-commit: ec43037d0f57fdfc2fdc4960fdb8a7e31ac79fae
2022-07-29 18:25:05 +08:00
André Martins
e9d4627252 client-go/rest: check if url is nil to prevent nil pointer dereference
Signed-off-by: André Martins <aanm90@gmail.com>

Kubernetes-commit: 94e7b2b8fdb4028b8b9d10ce57b9b33df146beb7
2022-08-09 14:19:01 +02:00
André Martins
c501ee0eba Revert "client-go: remove no longer used finalURLTemplate"
The functionality provided by the finalURLTemplate is still used by
certain external projects to track the request latency for requests
performed to kube-apiserver.

Using a template of the URL, instead of the URL itself, prevents the
explosion of label cardinality in exposed metrics since it aggregates
the URLs in a way that common URLs requests are reported as being the
same.

This reverts commit bebf5a608f68523fc430a44f6db26b16022dc862.

Signed-off-by: André Martins <aanm90@gmail.com>

Kubernetes-commit: f8f190cdd2fa76296f8b1b019ac77128b5d40b79
2022-08-08 23:27:45 +02: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
Davanum Srinivas
2a6c116e40 Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: a9593d634c6a053848413e600dadbf974627515f
2022-07-19 20:54:13 -04:00
ldsdsy
123d4e7e38 Fix a typo
Kubernetes-commit: bfe61fa574321474c4b278afb39af95464efad43
2022-06-20 21:52:50 +08:00
zhoumingcheng
84e1219642 Correct some wrong syntax
Signed-off-by: zhoumingcheng <zhoumingcheng@beyondcent.com>

Kubernetes-commit: e590ab77dcb68486a154b755aae658509b9290ea
2022-07-12 10:46:56 +08:00
saltbo
7c3fa18b11 fix: update the typo code comment
Kubernetes-commit: d2bab218ddef3fc3f444038420dd500c0e8bc068
2022-07-13 10:16:51 +08: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
Abu Kashem
71b8c174e4 client-go: fix backoff delay
Kubernetes-commit: 60e74a9ff73b206e5dd439b5df51ac9826635579
2022-05-17 17:19:26 -04:00
Abu Kashem
d8531f5ff0 client-go: make retry in Request thread safe
Kubernetes-commit: 6618b8ef7c0b552839555d4578b64427d20524ef
2022-03-29 13:09:26 -04:00
Abu Kashem
01ab7fb211 client-go: reset request body after response is read and closed
This commit refactors the retry logic to include resetting the
request body. The reset logic will be called iff it is not the
first attempt. This refactor is nescessary mainly because now
as per the retry logic, we always ensure that the request body
is reset *after* the response body is *fully* read and closed
in order to reuse the same TCP connection.

Previously, the reset of the request body and the call to read
and close the response body were not in the right order, which
leads to race conditions.

This commit also adds a test that verifies the order in which
the function calls are made to ensure that we seek only after
the response body is closed.

Co-authored-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: 68c8c458ee8f6629eef806c48c1a776dedad3ec4
2022-03-28 20:40:49 -04:00
Abu Kashem
7c9347d386 client-go: wrap error from previous attempt to provide more context
Kubernetes-commit: 868b5a31d382b325f49e1b831e6b094282d50cc7
2022-03-14 18:57:56 -04:00
Patrick Ohly
9175c47d17 enhance and fix log calls
Some of these changes are cosmetic (repeatedly calling klog.V instead of
reusing the result), others address real issues:

- Logging a message only above a certain verbosity threshold without
  recording that verbosity level (if klog.V().Enabled() { klog.Info... }):
  this matters when using a logging backend which records the verbosity
  level.

- Passing a format string with parameters to a logging function that
  doesn't do string formatting.

All of these locations where found by the enhanced logcheck tool from
https://github.com/kubernetes/klog/pull/297.

In some cases it reports false positives, but those can be suppressed with
source code comments.

Kubernetes-commit: edffc700a43e610f641907290a5152ca593bad79
2022-02-16 12:17:47 +01:00
Jordan Liggitt
83029168cc Temporarily disable TestCheckRetryClosesBody
Kubernetes-commit: 9c13a27d182c36296b7f2e381970b82c69d5c405
2022-03-24 10:11:06 -04:00
Abu Kashem
147848c452 client-go: chain the error returned by rate limiter
Kubernetes-commit: 6acbe7e6452a44057768c61909da2d5b7c878159
2022-02-24 17:28:01 -05:00
Abu Kashem
34f3aff43e client-go: refactor retry logic for backoff, rate limiter and metric
Kubernetes-commit: cecc563d3b9a9438cd3e6ae1576baa0a36f2d843
2022-02-17 16:57:45 -05:00
Antonio Ojea
e2c62ff0c0 client-go: add request and response size metrics
Get metrics for the request and response  size, so we can correlate latency
and size on a request, otherwise we could get confused because we don't know if the
network is slow or just the request size huge.

Kubernetes-commit: 64d9d0585f6dbc9266f31b6d0f795d6c0421495e
2021-12-09 12:11:01 +01:00
Abu Kashem
e4ecde2cf0 client-go: add unit test to verify order of calls
Kubernetes-commit: f6a66bbe051d2c7d537cf9033cc800babbb1a74b
2022-02-21 13:53:23 -05:00
Antonio Ojea
83bb1e3ff2 client-go: remove no longer used finalURLTemplate
The restclient metrics were updated to track only the host field of the
url, the finalURLTemplate is not longer needed, its only goal was to
replace name and namespace in the path to avoid cardinality.

Kubernetes-commit: bebf5a608f68523fc430a44f6db26b16022dc862
2022-02-17 16:51:55 +01:00
Davanum Srinivas
3bf0eac274 OWNERS cleanup - Jan 2021 Week 1
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 9682b7248fb69733c2a0ee53618856e87b067f16
2022-01-03 10:59:47 -05:00
Davanum Srinivas
73f2731e23 Cleanup OWNERS files (No Activity in the last year)
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 497e9c1971c9e7d0193bc6d11503ec4ad527f1d5
2021-12-10 15:18:50 -05:00
Davanum Srinivas
70f09c4943 Check in OWNERS modified by update-yamlfmt.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 9405e9b55ebcd461f161859a698b949ea3bde31d
2021-12-09 21:31:26 -05:00
Antonio Ojea
115ee0e475 bump TestHTTP1DoNotReuseRequestAfterTimeout timeout
the test TestHTTP1DoNotReuseRequestAfterTimeout has to wait for
request to time out to assert that subsequent requests does not
reuse the TCP connection.

It seems that current value of 100ms causes issues on some CI
environments and bumping the timeout seems to solve this flakiness,

We can bump the timeout value because is really low compared to real
scenarios and the bump still keeps it in the millisecond order.

Kubernetes-commit: 85797eba7075d83b116b5c91ff3b17c2d5118d01
2021-11-29 15:37:31 +01:00
Antonio Ojea
34c99305b5 remove unused fakeUpgradeConnection
Kubernetes-commit: bf9ce7fd76068903e909358d2b25b05da7e4a431
2021-11-16 22:54:18 +01:00
Antonio Ojea
d62dc4e20e no lint unused variables
Kubernetes-commit: 0019f986130fdd8ca17c6e5511b15168d9181b1e
2021-11-16 19:00:31 +01:00
Antonio Ojea
f34af1a39f CloseIdleConnections for wrapped Transport
It iterates over the wrapped transports until it finds one
that implements the CloseIdleConnections method and executes it.

add test for closeidle http1 connections

add test for http1.1 reconnect with inflight request

add test to reuse connection request

add test for request connect after timeout

add test for client-go request concurrency

Kubernetes-commit: b9d865a8185b62d83e9ff81b0e3499a26ac6960d
2021-09-10 15:27:23 +02:00
Antonio Ojea
fd09dceb88 RESTClient contructors for config and http client
Add two new constructors for versioned and unversioned RESTClients.

These new constructors allow to pass an http.Client to the RESTClient,
taking precence over the transport Config parameters.

Add a new helper function to generate an http.Client from the RESTClient
Config object.

Co-authored-by: Jordan Liggitt <liggitt@google.com>

Kubernetes-commit: 80fbc817263de1c46e1493819aca35b1ef8e3d09
2021-10-09 00:17:04 +02:00
Margo Crawford
e0129e64d4 Introduces Impersonate-Uid to client-go.
* Updates ImpersonationConfig in rest/config.go to include UID
  attribute, and pass it through when copying the config
* Updates ImpersonationConfig in transport/config.go to include UID
  attribute
* In transport/round_tripper.go, Set the "Impersonate-Uid" header in
  requests based on the UID value in the config
* Update auth_test.go integration test to specify a UID through the new
  rest.ImpersonationConfig field rather than manually setting the
  Impersonate-Uid header

Signed-off-by: Margo Crawford <margaretc@vmware.com>

Kubernetes-commit: d9ddfb26e10ee353fc4617b66d2c9274bf6d1c08
2021-07-30 15:50:51 -07:00
wojtekt
608b5216df Migrate to k8s.io/utils/clock in client-go - part 1
Kubernetes-commit: 950f655bdd19c5af275846cf1940d767a5ec0115
2021-09-15 10:58:56 +02:00
wojtekt
8d49a0b940 Migrate to k8s.io/utils/clock in flowcontrol backoff
Kubernetes-commit: 4ce452989bef21ab6d15bc659f463d8c706ad33e
2021-09-10 09:37:30 +02:00