Skip to content

Commit

Permalink
removes extra upgrade aware proxy logging; returns tunneling connecti…
Browse files Browse the repository at this point in the history
…on close error

Kubernetes-commit: e8bbb221d36f1adf4116752990c0c4f17a9e5deb
  • Loading branch information
seans3 authored and k8s-publishing-bot committed Mar 3, 2024
1 parent 808e708 commit 5ddec50
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions pkg/util/proxy/upgradeaware.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func (h *UpgradeAwareHandler) tryUpgrade(w http.ResponseWriter, req *http.Reques
} else {
writer = backendConn
}
_, err := io.Copy(writer, &loggingReader{name: "client->backend", delegate: requestHijackedConn})
_, err := io.Copy(writer, requestHijackedConn)
if err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
klog.Errorf("Error proxying data from client to backend: %v", err)
}
Expand All @@ -436,7 +436,7 @@ func (h *UpgradeAwareHandler) tryUpgrade(w http.ResponseWriter, req *http.Reques
} else {
reader = backendConn
}
_, err := io.Copy(requestHijackedConn, &loggingReader{name: "backend->client", delegate: reader})
_, err := io.Copy(requestHijackedConn, reader)
if err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
klog.Errorf("Error proxying data from backend to client: %v", err)
}
Expand All @@ -454,18 +454,6 @@ func (h *UpgradeAwareHandler) tryUpgrade(w http.ResponseWriter, req *http.Reques
return true
}

// loggingReader logs the bytes read from the "delegate" with a "name" prefix.
type loggingReader struct {
name string
delegate io.Reader
}

func (l *loggingReader) Read(p []byte) (int, error) {
n, err := l.delegate.Read(p)
klog.V(8).Infof("%s: %d bytes, err=%v, bytes=% X", l.name, n, err, p[:n])
return n, err
}

// FIXME: Taken from net/http/httputil/reverseproxy.go as singleJoiningSlash is not exported to be re-used.
// See-also: https://github.com/golang/go/issues/44290
func singleJoiningSlash(a, b string) string {
Expand Down

0 comments on commit 5ddec50

Please sign in to comment.