diff --git a/pkg/endpoints/handlers/rest.go b/pkg/endpoints/handlers/rest.go index 3728a3b77..5b76cfa45 100644 --- a/pkg/endpoints/handlers/rest.go +++ b/pkg/endpoints/handlers/rest.go @@ -25,7 +25,6 @@ import ( "net/http" "net/url" goruntime "runtime" - "strings" "time" "k8s.io/apimachinery/pkg/api/errors" @@ -195,10 +194,12 @@ func finishRequest(timeout time.Duration, fn resultFunc) (result runtime.Object, defer func() { panicReason := recover() if panicReason != nil { + // Same as stdlib http server code. Manually allocate stack + // trace buffer size to prevent excessively large logs const size = 64 << 10 buf := make([]byte, size) buf = buf[:goruntime.Stack(buf, false)] - panicReason = strings.TrimSuffix(fmt.Sprintf("%v\n%s", panicReason, string(buf)), "\n") + panicReason = fmt.Sprintf("%v\n%s", panicReason, buf) // Propagate to parent goroutine panicCh <- panicReason } diff --git a/pkg/server/filters/timeout.go b/pkg/server/filters/timeout.go index 4ade375a2..e79da50bf 100644 --- a/pkg/server/filters/timeout.go +++ b/pkg/server/filters/timeout.go @@ -99,6 +99,8 @@ func (t *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { defer func() { err := recover() if err != nil { + // Same as stdlib http server code. Manually allocate stack + // trace buffer size to prevent excessively large logs const size = 64 << 10 buf := make([]byte, size) buf = buf[:runtime.Stack(buf, false)]