From d17f0318cc2c5c7c0e7d27106a0fb102ffebef37 Mon Sep 17 00:00:00 2001 From: arkbriar Date: Wed, 24 Aug 2022 10:21:35 +0800 Subject: [PATCH] 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 Kubernetes-commit: 42808c8343671e6783ba4c901dcd619bed648c3d --- pkg/cmd/attach/attach.go | 3 ++- pkg/cmd/exec/exec.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/attach/attach.go b/pkg/cmd/attach/attach.go index 668524ab6..e403b5208 100644 --- a/pkg/cmd/attach/attach.go +++ b/pkg/cmd/attach/attach.go @@ -17,6 +17,7 @@ limitations under the License. package attach import ( + "context" "fmt" "io" "net/url" @@ -159,7 +160,7 @@ func (*DefaultRemoteAttach) Attach(method string, url *url.URL, config *restclie if err != nil { return err } - return exec.Stream(remotecommand.StreamOptions{ + return exec.StreamWithContext(context.Background(), remotecommand.StreamOptions{ Stdin: stdin, Stdout: stdout, Stderr: stderr, diff --git a/pkg/cmd/exec/exec.go b/pkg/cmd/exec/exec.go index f3be195db..ff7a3750d 100644 --- a/pkg/cmd/exec/exec.go +++ b/pkg/cmd/exec/exec.go @@ -122,7 +122,7 @@ func (*DefaultRemoteExecutor) Execute(method string, url *url.URL, config *restc if err != nil { return err } - return exec.Stream(remotecommand.StreamOptions{ + return exec.StreamWithContext(context.Background(), remotecommand.StreamOptions{ Stdin: stdin, Stdout: stdout, Stderr: stderr,