56 Commits

Author SHA1 Message Date
Mikhail Mazurskiy
d21662ddfc Decouple term and remotecommand packages
This allows consumers of term to not pull in dependencies on
github.com/gorilla/websocket and github.com/moby/spdystream.

Kubernetes-commit: 640dabd58b04b72f646ed85947cb8b407b36dc08
2025-08-03 20:35:40 +10:00
xuzhenglun
2f016580ef make sure all streams are created before starting demux websocket
Kubernetes-commit: 3379d5ac4b6a1afbbaead06689a8584ce546a275
2025-07-08 18:31:30 +08:00
Patrick Ohly
804ee8c42e client-go remotecommand: avoid "unexpected error" log when there is no error
Normal execution always started to trigger this after adding more logging in
the E2E framework's exec_util.go:

     I0506 21:23:56.781188 6341 exec_util.go:201] unexpected error trying to use websockets for pod exec: <nil>

That the "should fall back" implementation gets called when there is no error
and thus no reason to even consider falling back is odd. Now the execute
implementation checks for nil first.

This is the same approach taken also in the portforward code:
b35c5c0a30/staging/src/k8s.io/client-go/tools/portforward/fallback_dialer.go (L52)

Kubernetes-commit: 35870c480d64a8ae35c0e5839cc40b0115b7328a
2025-05-07 14:51:18 +02:00
Sean Sullivan
c77f9e4f9e Websocket HTTPS proxy support
Kubernetes-commit: f73945aae56b51078318199ff2f0ecae91bc489e
2025-01-29 03:56:55 +00:00
Maciej Zimnoch
c1ee4cc22c Return correct error upon websocket message read failure
This fixes variable passed as error reason upon websocker message read failure.
Previously a wrong variable was passed resulting in returning failure with nil error reason.

Kubernetes-commit: e1d3aaf8612c490fae965272a304d74fccf7e294
2025-03-07 12:53:47 +01: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
Sean Sullivan
3ead27a3a2 Update websocket logging levels for better debuggability
Kubernetes-commit: d3feb5080c18fa73aa87c81a78d5cac82c6ed06d
2025-02-11 20:20:23 +00:00
Tiago Silva
9f1cce41d5 client-go: transform watchErrorStream to wrap the underlying error (#129765)
* `client-go`: transform `watchErrorStream` to wrap the underlying error

This PR transforms the `client-go`'s `watchErrorStream` to wrap the error instead of transforming it into a single string. This enables clients to use `errors.Is/As/Unwrap` with the errors that come out of `StreamWithContext`

Fixes https://github.com/kubernetes/kubernetes/issues/129763

* adjust unit tests

Kubernetes-commit: 067012f5844b7390e7279f575342ae0536f80520
2025-01-23 20:07:37 +00: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
Abhishek Kr Srivastav
7141d012f4 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: 95860cff1c418ea6f5494e4a6168e7acd1c390ec
2024-09-12 18:15:22 +05:30
Sean Sullivan
6e31289fcf moving for easier cherry-pick
Kubernetes-commit: bc526472515e1a01d41e5a94db2b74462545c984
2024-07-20 05:29:57 -07:00
Sean Sullivan
8108d4122f Falls back to SPDY for gorilla/websocket https proxy error
Kubernetes-commit: 9d560540c5268e0e2aebf5306907494cf522c260
2024-07-19 12:04:41 -07:00
Sean Sullivan
0b664571bb Adds logging during remote command executor fallback
Kubernetes-commit: d8269e5a394dfa0116e8baeb7aac0a82eb430e5e
2024-06-16 13:51:09 -07:00
Sean Sullivan
62aace94ab Adds OWNERS files to client-go streaming dirs
Kubernetes-commit: 855bc74023900b31095de72ae49c79d5d391aad5
2024-03-05 20:21:48 +00:00
Sean Sullivan
ae38726e6e extend deadlines to one minute
Kubernetes-commit: b04d1177efb0cfc84b76732848eef8f0ea89b25b
2024-03-04 11:31:56 -08:00
Sean Sullivan
f759d2e976 increases client-side websocket write deadline to 30 seconds
Kubernetes-commit: 1d4be7527f8b2d2c4eb6dcc7ef58b4c3133f6f19
2024-03-01 18:16:44 -08:00
Jordan Liggitt
27b1407865 Keep streams from being set up after closeAllStreamReaders is called
Kubernetes-commit: 6c1a935da2df8e6ccf1ea6afcf51cb288f355356
2024-02-29 15:31:55 -05:00
Jordan Liggitt
36a771f98c Make websocket heartbeat test timing less flaky
Kubernetes-commit: 26484df2108eff8ad6e06dfc960eae3bdfbf4663
2024-02-29 15:10:28 -05:00
Sean Sullivan
7eae79e001 remote command turn on feature gates
Kubernetes-commit: a147693deb2e7f040cf367aae4a7ae5d1cb3e7aa
2024-02-13 14:10:40 -08:00
Sean Sullivan
b7d73dd18c StreamTranslator and FallbackExecutor for WebSockets
Kubernetes-commit: 168998e87bfd49a1b0bc6402761fafd5ace3bb3b
2023-07-06 21:22:07 -07: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
Antonio Ojea
011db228a8 deflake TestWebSocketClient_HeartbeatSucceeds
Change-Id: I1f3331255ed81183b25ec24084c00d0cf7dfb510

Kubernetes-commit: 4a74958b2df7ecd9e6a4867f7b10f1402cb2e215
2023-09-25 10:31:46 +00: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
Sean Sullivan
fd1e22bd8f WebSocket Client and V5 RemoteCommand Subprotocol
Kubernetes-commit: a0d6a815fcc02cbfea1bb22d13a8e896ecbe116c
2023-07-06 21:22:07 -07: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
Antonio Ojea
9ed804b6d5 improve remotecommand testing fuzzing the data stream
Change-Id: I1303bc79a8c43fc4fb04bf76afcf90653ceb9e14

Kubernetes-commit: 60d25c3ed77cbd8341fc7ae984e165e7046e5c9b
2023-03-01 19:56:41 +00:00
arkbriar
0563decd0a Propagate the panic with a channel
Signed-off-by: arkbriar <arkbriar@gmail.com>

Kubernetes-commit: b7e6c23e9f73e4cc0209e94fe95c5e2809998bf6
2022-11-02 11:36:22 +08:00
arkbriar
2362c7b162 use subtests and defer in TestSPDYExecutorStream
Signed-off-by: arkbriar <arkbriar@gmail.com>

Kubernetes-commit: 86e5d069ecece8591ad693b50bcea49000f6df26
2022-10-10 11:24:40 +08:00
arkbriar
5e0a53136c Support cancelable SPDY executor stream
Mark remotecommand.Executor as deprecated and related modifications.

Handle crash when streamer.stream panics

Add a test to verify if stream is closed after connection being closed

Remove blank line and update waiting time to 1s to avoid test flakes in CI.

Refine the tests of StreamExecutor according to comments.

Remove the comment of context controlling the negotiation progress and misc.

Signed-off-by: arkbriar <arkbriar@gmail.com>

Kubernetes-commit: 42808c8343671e6783ba4c901dcd619bed648c3d
2022-08-24 10:21:35 +08:00
Monis Khan
166580894e Use https links for k8s KEPs, issues, PRs, etc
Signed-off-by: Monis Khan <mok@microsoft.com>

Kubernetes-commit: b738be9b46a899571303c8c887e32bf4d5b71a0a
2022-09-23 16:13:22 -04: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
adamzhoul
5c32e970ce fix replyChan block
Kubernetes-commit: 314a9c4a6215b7e57944c86acacc5c75ab55121f
2021-01-11 08:36:27 +00:00
Rajalakshmi-Girish
cb8d3d1111 fixes the unit tests to be more tolerant with error messages
Kubernetes-commit: 98948ad8092b41ebc08d50aa557b2d7ba5496e7d
2020-11-27 08:21:56 +00:00
adamzhoul
04adad44d6 fix spdy stream, conn deadlock.
Kubernetes-commit: 94a297485bf39a6d69f316c257d351e9432b8cb5
2020-11-15 17:06:34 +08:00
Davanum Srinivas
75fea27a27 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
Jordan Liggitt
5a40e141bd Fix sending oversided data frames to spdy stream
Kubernetes-commit: 0202e269a3deb7ff96d3b9e3fce767c4b37a766e
2018-11-13 10:57:33 -05:00
Davanum Srinivas
74cd8bbeee 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
Yann Hodique
58a34f32bd client-go: update documentation for remotecommand.StreamOptions
The ability to explicitly define the supported protocols was removed in commit 12c7874c0d88e9099ab2a29915d26751f0d23c2a
Adjust documentation accordingly.

Kubernetes-commit: f77060aa8da8256fa48412e7a0d9523245017dcb
2018-07-16 14:43:54 -07:00
Kubernetes Publisher
fff8c3d73e sync: initially remove files BUILD */BUILD BUILD.bazel */BUILD.bazel 2018-03-15 09:19:38 +00:00
Jeff Grafton
fca8bb2928 Autogenerated: hack/update-bazel.sh
Kubernetes-commit: ef56a8d6bb3800ab7803713eafc4191e8202ad6e
2018-02-16 13:43:01 -08:00
Jeff Grafton
fe985a55a2 Autogenerate BUILD files
Kubernetes-commit: efee0704c60a2ee3049268a41535aaee7f661f6c
2017-12-23 13:06:26 -08:00
Jordan Liggitt
7841216303 Allow constructing spdy executor from existing transports
Kubernetes-commit: f82b1ba90ecfff0eb5731ba4da0b6f8acf79d3ff
2017-11-17 15:47:46 -05:00
Jeff Grafton
c92755ea3b update BUILD files
Kubernetes-commit: aee5f457dbfd70c2d15c33e392dce6a3ca710116
2017-10-12 13:52:10 -07:00
Jeff Grafton
5da217e5c4 Use buildozer to delete licenses() rules except under third_party/
Kubernetes-commit: a7f49c906df816123e7d4ccbd4cebab411519465
2017-08-29 12:51:55 +00:00
Jeff Grafton
fa2ceb7462 Use buildozer to remove deprecated automanaged tags
Kubernetes-commit: 33276f06be5e872bf53ca62a095fcf0a6b6c11a8
2017-08-29 12:51:55 +00:00
Jeff Grafton
f921a73942 Run hack/update-bazel.sh to generate BUILD files
Kubernetes-commit: 3579017b865ddbc5449d6bba87346f086e4b93ff
2017-08-29 12:50:17 +00:00
Clayton Coleman
3bb413eede Move SPDY specific code into its own package
Kubernetes-commit: cf026a3314fd3513a2c4239c6f4edbbbbcb96a77
2017-07-16 03:58:42 +00:00
Clayton Coleman
4e62d7d64d Prepare to introduce websockets for exec and portforward
Refactor the code in remotecommand to better represent the structure of
what is common between portforward and exec.

Kubernetes-commit: 12c7874c0d88e9099ab2a29915d26751f0d23c2a
2017-07-16 03:58:42 +00:00