Merge pull request #128318 from soltysh/kubelet_port_forward

Reset streams when an error happens during port-forward (part 1/2)
This commit is contained in:
Kubernetes Prow Robot 2024-10-25 18:33:10 +01:00 committed by GitHub
commit e79722d98a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}
}