Skip to content

Commit aa11f24

Browse files
committed
Reset streams when an error happens during port-forward
Signed-off-by: Maciej Szulik <[email protected]>
1 parent d9b95ea commit aa11f24

File tree

1 file changed

+6
-0
lines changed
  • staging/src/k8s.io/kubelet/pkg/cri/streaming/portforward

1 file changed

+6
-0
lines changed

staging/src/k8s.io/kubelet/pkg/cri/streaming/portforward/httpstream.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ func (h *httpStreamHandler) portForward(p *httpStreamPair) {
256256
msg := fmt.Errorf("error forwarding port %d to pod %s, uid %v: %v", port, h.pod, h.uid, err)
257257
utilruntime.HandleError(msg)
258258
fmt.Fprint(p.errorStream, msg.Error())
259+
// receiving an error from a port-forward operation indicates a problem
260+
// with data stream most probably, thus we want to reset the streams
261+
// indicating there was a problem and allow a new set of streams be
262+
// created to mitigate the problem
263+
p.dataStream.Reset() // nolint:errcheck
264+
p.errorStream.Reset() // nolint:errcheck
259265
}
260266
}
261267

0 commit comments

Comments
 (0)