Remove TLS EOF errors from logs (#16930)

Signed-off-by: Manuel de Brito Fontes <aledbf@gmail.com>
This commit is contained in:
Manuel Alejandro de Brito Fontes 2023-03-21 06:23:13 -03:00 committed by GitHub
parent b1ab625626
commit aa61917989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,16 +5,18 @@
package proxy package proxy
import ( import (
"bytes"
"crypto/tls" "crypto/tls"
stdlog "log"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"github.com/gitpod-io/golang-crypto/ssh"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/klauspost/cpuid/v2" "github.com/klauspost/cpuid/v2"
"github.com/gitpod-io/gitpod/common-go/log" "github.com/gitpod-io/gitpod/common-go/log"
"github.com/gitpod-io/golang-crypto/ssh"
) )
// WorkspaceProxy is the entity which forwards all inbound requests to the relevant workspace pods. // WorkspaceProxy is the entity which forwards all inbound requests to the relevant workspace pods.
@ -64,6 +66,7 @@ func (p *WorkspaceProxy) MustServe() {
PreferServerCipherSuites: true, PreferServerCipherSuites: true,
NextProtos: []string{"h2", "http/1.1"}, NextProtos: []string{"h2", "http/1.1"},
}, },
ErrorLog: stdlog.New(logrusErrorWriter{}, "", 0),
} }
var ( var (
@ -141,3 +144,16 @@ func optimalDefaultCipherSuites() []uint16 {
} }
return defaultCipherSuitesWithoutAESNI return defaultCipherSuitesWithoutAESNI
} }
var tlsHandshakeErrorPrefix = []byte("http: TLS handshake error")
type logrusErrorWriter struct{}
func (w logrusErrorWriter) Write(p []byte) (int, error) {
if bytes.Contains(p, tlsHandshakeErrorPrefix) {
return len(p), nil
}
log.Errorf("%s", string(p))
return len(p), nil
}