Skip to content

Commit f507f28

Browse files
committed
apimachinery: hide 'suppressing panic for copyResponse' error' in ReverseProxy
1 parent bb496d6 commit f507f28

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

staging/src/k8s.io/apimachinery/pkg/util/proxy/upgradeaware.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ import (
2323
"fmt"
2424
"io"
2525
"io/ioutil"
26+
"log"
2627
"net"
2728
"net/http"
2829
"net/http/httputil"
2930
"net/url"
31+
"os"
3032
"strings"
3133
"time"
3234

@@ -230,9 +232,22 @@ func (h *UpgradeAwareHandler) ServeHTTP(w http.ResponseWriter, req *http.Request
230232
proxy := httputil.NewSingleHostReverseProxy(&url.URL{Scheme: h.Location.Scheme, Host: h.Location.Host})
231233
proxy.Transport = h.Transport
232234
proxy.FlushInterval = h.FlushInterval
235+
proxy.ErrorLog = log.New(noSuppressPanicError{}, "", log.LstdFlags)
233236
proxy.ServeHTTP(w, newReq)
234237
}
235238

239+
type noSuppressPanicError struct{}
240+
241+
func (noSuppressPanicError) Write(p []byte) (n int, err error) {
242+
// skip "suppressing panic for copyResponse error in test; copy error" error message
243+
// that ends up in CI tests on each kube-apiserver termination as noise and
244+
// everybody thinks this is fatal.
245+
if strings.Contains(string(p), "suppressing panic") {
246+
return len(p), nil
247+
}
248+
return os.Stderr.Write(p)
249+
}
250+
236251
// tryUpgrade returns true if the request was handled.
237252
func (h *UpgradeAwareHandler) tryUpgrade(w http.ResponseWriter, req *http.Request) bool {
238253
if !httpstream.IsUpgradeRequest(req) {

0 commit comments

Comments
 (0)