mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-26 15:12:06 +00:00
Propagate the panic with a channel
Signed-off-by: arkbriar <arkbriar@gmail.com> Kubernetes-commit: b7e6c23e9f73e4cc0209e94fe95c5e2809998bf6
This commit is contained in:
parent
2362c7b162
commit
0563decd0a
@ -27,9 +27,8 @@ import (
|
|||||||
|
|
||||||
"k8s.io/apimachinery/pkg/util/httpstream"
|
"k8s.io/apimachinery/pkg/util/httpstream"
|
||||||
"k8s.io/apimachinery/pkg/util/remotecommand"
|
"k8s.io/apimachinery/pkg/util/remotecommand"
|
||||||
"k8s.io/apimachinery/pkg/util/runtime"
|
|
||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
spdy "k8s.io/client-go/transport/spdy"
|
"k8s.io/client-go/transport/spdy"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StreamOptions holds information pertaining to the current streaming session:
|
// StreamOptions holds information pertaining to the current streaming session:
|
||||||
@ -161,14 +160,20 @@ func (e *streamExecutor) StreamWithContext(ctx context.Context, options StreamOp
|
|||||||
}
|
}
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
|
|
||||||
|
panicChan := make(chan any, 1)
|
||||||
errorChan := make(chan error, 1)
|
errorChan := make(chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
defer runtime.HandleCrash()
|
defer func() {
|
||||||
defer close(errorChan)
|
if p := recover(); p != nil {
|
||||||
|
panicChan <- p
|
||||||
|
}
|
||||||
|
}()
|
||||||
errorChan <- streamer.stream(conn)
|
errorChan <- streamer.stream(conn)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
case p := <-panicChan:
|
||||||
|
panic(p)
|
||||||
case err := <-errorChan:
|
case err := <-errorChan:
|
||||||
return err
|
return err
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
Loading…
Reference in New Issue
Block a user