Commit Graph

656 Commits

Author SHA1 Message Date
Abhishek Kr Srivastav
e461ee1f4c Fix Go vet errors for master golang
Co-authored-by: Rajalakshmi-Girish <rajalakshmi.girish1@ibm.com>
Co-authored-by: Abhishek Kr Srivastav <Abhishek.kr.srivastav@ibm.com>

Kubernetes-commit: 5bf390ad00287ee0cb939376bd9151ea402b59b6
2024-09-12 18:15:22 +05:30
Jordan Liggitt
cc211226f0 Keep streams from being set up after closeAllStreamReaders is called
Kubernetes-commit: efd8578ac75459df19e7589b2767fbdbbc288383
2024-02-29 15:31:55 -05:00
Jordan Liggitt
8636987d11 Make websocket heartbeat test timing less flaky
Kubernetes-commit: 4499c3fadcd468678663fed28a2fcf066d2daafe
2024-02-29 15:10:28 -05:00
Sean Sullivan
b7d73dd18c StreamTranslator and FallbackExecutor for WebSockets
Kubernetes-commit: 168998e87bfd49a1b0bc6402761fafd5ace3bb3b
2023-07-06 21:22:07 -07:00
tao.yang
0447e1f9ce cleanup: omit comparison with bool constants
Signed-off-by: tao.yang <tao.yang@daocloud.io>

Kubernetes-commit: b35357b6c08f21ba0fd312536051394c2567ec79
2023-09-04 16:59:23 +08:00
Lukasz Szaszkiewicz
0f984dc7fc client-go/reflector: introduce a data consistency mechanism for the watch-list feature.
checkWatchListConsistencyIfRequested performs a data consistency check only when
the KUBE_WATCHLIST_INCONSISTENCY_DETECTOR environment variable was set during a binary startup.

The consistency check is meant to be enforced only in the CI, not in production.
The check ensures that data retrieved by the watch-list api call
is exactly the same as data received by the standard list api call.

Note that this function will panic when data inconsistency is detected.
This is intentional because we want to catch it in the CI.

Kubernetes-commit: b31e7793d0d873a71c90caf8455556aa905cf88d
2023-10-06 14:26:47 +02:00
Arda Güçlü
583e50d008 Use timeout function to detect transient errors
Kubernetes-commit: a888fef242fd59bc3871c67099c7f5e9449873c2
2023-10-06 08:55:22 +03:00
Arda Güçlü
9a88950e38 revert back to IsUnexpectedCloseError check
Kubernetes-commit: 914210ee9a6df6927019f200e90534edd1460fea
2023-10-05 12:04:06 +03:00
Arda Güçlü
e95d92dbc6 Close websocket heartbeat explicitly when unexpected closure received
Kubernetes-commit: e1ae906048003145441fb1d4ecce4c13acf5cb19
2023-10-03 12:05:26 +03:00
Patrick Ohly
cf07629bfe k8s.io/client-go/tools/events: pass context into EventSink methods
Because the EventBroadcaster code now has a a context, changing the EventSink
interface so that the methods accepts a context instead of using context.TODO
becomes possible.

Kubernetes-commit: 5dc540ff57eed5d0e6bc8476f95fe03b7a983cf5
2023-09-18 12:17:14 +02:00
Patrick Ohly
3595e5242a k8s.io/client-go/tools: support context for event recording
Using StartRecordingToSinkWithContext instead of StartRecordingToSink and
StartLogging instead of StartStructuredLogging has several advantages:

- Spawned goroutines no longer get stuck for extended periods of
  time during shutdown when passing in a context that gets canceled.
- Log output can be directed towards a specific logger instead of the global
  default, for example one which writes to a testing.T instance.
- The new methods return an error when something went wrong instead of
  merely recording the error.

That last point is the reason for deprecating the old methods instead of merely
adding new alternatives.

Setting a context when constructing an EventBroadcaster makes calling Shutdown
optional. It can also be used to specify the logger.

Both EventRecorder interfaces in tools/events and tools/record now have a
WithLogger helper. Using that method is optional, but recommended to support
contextual logging properly. Without it, errors that occur while emitting an
event are not associated with the caller.

Kubernetes-commit: 27a68aee3a48340f7c14235f7fc24aa69aaeb8f6
2023-09-18 09:13:22 +02:00
Lukasz Szaszkiewicz
1e0855a7ac reflector: fallback to the previous mode on any error
originally we honored only apierrors.IsInvalid
but decided to fallback on every error
because it is better to make progress than deadlocking

Kubernetes-commit: 4b3915017950a114124a88c5d308bd8bfb9ec48e
2023-10-04 08:17:10 +02:00
Lukasz Szaszkiewicz
2c9d749027 reflector: close an established watcher when the StopCh was closed
Kubernetes-commit: 26f113be2fc71c7a41a59145eee5d4da9d062b9e
2023-10-03 13:49:21 +02:00
Antonio Ojea
011db228a8 deflake TestWebSocketClient_HeartbeatSucceeds
Change-Id: I1f3331255ed81183b25ec24084c00d0cf7dfb510

Kubernetes-commit: 4a74958b2df7ecd9e6a4867f7b10f1402cb2e215
2023-09-25 10:31:46 +00:00
Lukasz Szaszkiewicz
d0ea06d597 cache/reflector: check the value of the initial-events-end annotation
Kubernetes-commit: 04668c00432cbd552b08eb94f829643facbd2061
2023-09-19 12:59:23 +02:00
Antonio Ojea
ea6e035481 add loging and bump timers to avoid races
Change-Id: I6da35b6fb33c939f3f92f8ebf4c6a18bdf1644e4

Kubernetes-commit: 40618b765ccb1a0e75f7063534f9645d1df57f7a
2023-09-15 08:23:58 +00:00
devincd
f242a563ef fix typo in client-go package
Signed-off-by: devincd <505259926@qq.com>

Kubernetes-commit: 975da2fb2393350db504e50652b17c70206e1407
2023-09-08 10:31:07 +08:00
Sean Sullivan
fd1e22bd8f WebSocket Client and V5 RemoteCommand Subprotocol
Kubernetes-commit: a0d6a815fcc02cbfea1bb22d13a8e896ecbe116c
2023-07-06 21:22:07 -07:00
Dr. Stefan Schimanski
00f8b3aa35 client-go: log proper 'caches populated' message, with type and source and only once
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>

Kubernetes-commit: a1809ffae377f3abbae12b137073ca4c473743cd
2023-08-07 12:56:32 +02:00
Stephen Kitt
caded3c2dc api-machinery: stop using deprecated io/ioutil
This replaces deprecated ioutil functions as follows:

* ioutil.ReadAll -> io.ReadAll
* ioutil.ReadFile -> os.ReadFile
* ioutil.TempDir -> os.MkdirTemp
* ioutil.TempFile -> os.CreateTemp
* ioutil.WriteFile -> os.WriteFile

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

Kubernetes-commit: b60a3a58df2791ae67764f6325be31aea5eca5a0
2023-05-02 15:08:18 +02: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
Sunil Shivanand
aea98eb150 combine conditional checks
Signed-off-by: Sunil Shivanand <sunil.shivanand@statnett.no>

Kubernetes-commit: 80480f8e21572cba152a4f6f171ebb5de8c6bafb
2023-01-11 09:45:37 +01:00
Sunil Shivanand
0d54cf50db handle event errors caused due to terminating namespaces
Create events are forbidden in terminating namespaces, use info
instead of error to log the failed event.

Signed-off-by: Sunil Shivanand <sunil.shivanand@statnett.no>

Kubernetes-commit: 7a6d58001b7d824f92601fd246b3aad9fbb9c583
2023-01-05 12:56:40 +01:00
Chris Bandy
3ffcfabea2 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: ac5ce5cbce7ddb6ffeff755d1cf670afadb8e1fb
2023-06-05 21:03:21 -05:00
John Howard
702d7378b6 informer: fix race against Run and SetTransform/SetWatchErrorHandler
`SetWatchErrorHandler` claims it will fail if Run() has already started.
But if they are called concurrently, it will actually trigger a data
race.

With this PR:
```
62702 runs so far, 0 failures (100.00% pass rate). 59.152682ms avg, 189.068387ms max, 26.623785ms min
```

Without this PR:
```
5012 runs so far, 38 failures (99.25% pass rate). 58.675502ms avg, 186.018084ms max, 29.468104ms min
```

Kubernetes-commit: 35d2431b3a89c5bd693846952e9d27ce4e3a0754
2023-05-08 10:11:54 -07:00
scott
6c7d1bc996 Add WithAlloc interface and stub implementations with base benchmarks
Kubernetes-commit: b8a3bd673dc61b4d7a0ad0f54fa423e0160078cf
2023-05-27 17:57:35 -04:00
Marcel Zieba
bae10246dd Improve backoff policy in reflector.
Before, we've used two separate backoff managers for List and Watch
calls, now they share single backoff manager.

Kubernetes-commit: 337728b02559dec8a613fdef174f732da9cae310
2023-05-19 14:28:31 +02:00
Johan Oskarsson
0011bf6b0b Validate lock identity
Ensure that the lock identity is not empty. This can cause unexpected issues during leader election.

Kubernetes-commit: 5519b89a28eeea5a5b134092242aff770fcc07eb
2023-05-16 09:41:18 -07:00
kkkkun
3195e36899 Should get ENABLE_CLIENT_GO_WATCH_LIST_ALPHA when new reflector
Signed-off-by: kkkkun <scuzk373x@gmail.com>

Kubernetes-commit: 2eed9b4143a9009b3327003ae50dbbebb44d2841
2023-05-24 21:09:53 +08: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
Arda Güçlü
4cb373f7ca Add warning log callback in client-go loading rules (#117233)
* Add warning log callback in client-go loading rules

This provides a way to consumers use their own custom warning
mechanisms instead default klog warning.

* Use typed error instead plain string

* Fix interface change in unit test

Kubernetes-commit: 2ea6896f90c8b757d8a247d393b9a13fff2dab58
2023-05-24 18:20:07 +00:00
Daniel Smith
aa75d3bd59 lavalamp is taking a long break
Kubernetes-commit: 1ffe3f467e8b8033312b7c68943d58125fd27663
2023-05-11 16:43:38 +00:00
Antonio Ojea
7cf3125431 add new metrics for the internal client-go transport generator
Add two new metrics to monitor the client-go logic that
generate http.Transports for the clients.

- rest_client_transport_cache_entries is a gauge metrics
with the number of existin entries in the internal cache

- rest_client_transport_create_calls_total is a counter
that increments each time a new transport is created, storing
the result of the operation needed to generate it: hit, miss
or uncacheable

Change-Id: I2d8bde25281153d8f8e8faa249385edde3c1cb39

Kubernetes-commit: 3f3e1d507d081528ce8081f0daf4446d8a3b9bc0
2023-05-10 22:40:13 +00:00
HirazawaUi
0a0ddf8b6b generate ReportingInstance and ReportingController in Event
Kubernetes-commit: df0a25382053bb6c0f04fc4d807be6e059b552c1
2023-03-27 22:23:45 +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
Tim Hockin
54190dfee5 Clean up brace whitespace in **/validation_test.go
This was making my eyes bleed as I read over code.

I used the following in vim.  I made them up on the fly, but they seemed
to pass manual inspection.

:g/},\n\s*{$/s//}, {/
:w
:g/{$\n\s*{$/s//{{/
:w
:g/^\(\s*\)},\n\1},$/s//}},/
:w
:g/^\(\s*\)},$\n\1}$/s//}}/
:w

Kubernetes-commit: d55b67b349021b6c46fc6ce78f2a36bd4217145f
2023-05-02 00:36:15 -07:00
Shiming Zhang
3b78b11d95 Add json tag
Kubernetes-commit: d0677f528c03ff5556830bc2e9b9c40824b160ee
2023-05-01 23:05:32 +08:00
Shiming Zhang
1ec6a37b5c Fix LocationOfOrigin shows up unexpectedly
Kubernetes-commit: 4d9261c7567a7498d16754b7c5bf3b9ea834e5a6
2023-04-25 10:58:07 +08:00
Msk233
5d5619d392 stop watcher when error occurs
Kubernetes-commit: da3e7e3781650024e4cc7cb65082908c531e8efa
2023-04-26 09:04:33 +08:00
Antonio Ojea
9ed804b6d5 improve remotecommand testing fuzzing the data stream
Change-Id: I1303bc79a8c43fc4fb04bf76afcf90653ceb9e14

Kubernetes-commit: 60d25c3ed77cbd8341fc7ae984e165e7046e5c9b
2023-03-01 19:56:41 +00:00
Wojciech Tyczyński
27bbe76535 Remove support for EndpointsLeases and ConfigMapsLeases lock from leader election
Kubernetes-commit: 2bd42061b6e8035c3def54545ccc4baf95bd6586
2023-04-24 15:08:10 +02:00
Hao Ruan
ef522cc423 replace spew methods with dump methods
Kubernetes-commit: c4e1b01416ec05e6a520a181d4ce3b4333adb4e4
2023-04-13 09:41:07 +08: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
Tim Hockin
c4339eeca9 Replace uses of ObjectGoPrintDiff with cmp.Diff
ObjectGoPrintDiff is already a shim over cmp.Diff, so no actual output
or behavior changes

Kubernetes-commit: 9627c50ef37f3b5274486e6f5ad37b73b1b69bf0
2023-03-23 11:31:25 -07:00
Mike Spreitzer
8301a60862 Added conversions to/from NamespacedName
Also renamed file to something more on-point.

Kubernetes-commit: 8d92cfb13163f596feddfe1b5e734fd1ba4f6323
2023-03-22 16:55:07 -04:00
Mike Spreitzer
42799afb70 Add structured alternatives to strings in client-go/tools/cache
Kubernetes-commit: ec9515a828ec3907ffc66913947adf4e8ee7b9d6
2023-03-22 16:21:17 -04:00
Hao Ruan
db3650d98f replaced spew.Sprintf with a util pretty print function
Kubernetes-commit: f638e2849fbddeb201b8290586a4747af99086bf
2023-01-04 14:12:56 +08:00
Daniel Smith
c3b84f0438 Change where transformers are called.
Kubernetes-commit: e76dff38cf74c3c8ad9ed4d3bc6e3641d9b64565
2023-03-14 23:05:20 +00:00
Clayton Coleman
250fc3d6b4 wait: Update tests to reference the constant error
The structure of the error is changing, and we don't guarantee
reflect.DeepEqual(...) will remain true for ErrWaitTimeout currently.

Kubernetes-commit: 8d4004bbc77d012642db97e09238f4f65a926bca
2023-03-10 11:02:59 -06:00
Damien Grisonnet
9c7c60b695 events: fix EventSeries starting count discrepancy
The kube-apiserver validation expects the Count of an EventSeries to be
at least 2, otherwise it rejects the Event. There was is discrepancy
between the client and the server since the client was iniatizing an
EventSeries to a count of 1.

According to the original KEP, the first event emitted should have an
EventSeries set to nil and the second isomorphic event should have an
EventSeries with a count of 2. Thus, we should matcht the behavior
define by the KEP and update the client.

Also, as an effort to make the old clients compatible with the servers,
we should allow Events with an EventSeries count of 1 to prevent any
unexpected rejections.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>

Kubernetes-commit: d00364902bda05eed4f7f02051ab81f7be55f8a9
2022-09-08 23:50:41 +02:00