From aa11f2461fe06fccbd494aa7a837a04cf80507f0 Mon Sep 17 00:00:00 2001 From: Maciej Szulik Date: Wed, 23 Oct 2024 13:30:01 +0200 Subject: [PATCH] Reset streams when an error happens during port-forward Signed-off-by: Maciej Szulik --- .../kubelet/pkg/cri/streaming/portforward/httpstream.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/staging/src/k8s.io/kubelet/pkg/cri/streaming/portforward/httpstream.go b/staging/src/k8s.io/kubelet/pkg/cri/streaming/portforward/httpstream.go index a45131081a8..4d38f454cb6 100644 --- a/staging/src/k8s.io/kubelet/pkg/cri/streaming/portforward/httpstream.go +++ b/staging/src/k8s.io/kubelet/pkg/cri/streaming/portforward/httpstream.go @@ -256,6 +256,12 @@ func (h *httpStreamHandler) portForward(p *httpStreamPair) { msg := fmt.Errorf("error forwarding port %d to pod %s, uid %v: %v", port, h.pod, h.uid, err) utilruntime.HandleError(msg) fmt.Fprint(p.errorStream, msg.Error()) + // receiving an error from a port-forward operation indicates a problem + // with data stream most probably, thus we want to reset the streams + // indicating there was a problem and allow a new set of streams be + // created to mitigate the problem + p.dataStream.Reset() // nolint:errcheck + p.errorStream.Reset() // nolint:errcheck } }