Skip to content

Commit

Permalink
log: avoid log spam with monitoring probes on the HTTP port
Browse files Browse the repository at this point in the history
Prior to this patch, a monitoring probe that would just open and close
the HTTP port would cause log spam like the following:

```
E201007 11:21:57.101735 882 (gostd) net/http/server.go:3088  http: TLS handshake error from 127.0.0.1:24059: EOF
```

This patch removes it.

(This was tested by using netcat: `nc 127.0.0.1 8080` and then Ctrl+C
to immediately close the connection.)

Release note: None
  • Loading branch information
knz committed Oct 7, 2020
1 parent 9b5e5a4 commit 0f0ad1d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/util/log/log_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"context"
"fmt"
stdLog "log"
"regexp"
"strconv"
"strings"
)
Expand Down Expand Up @@ -58,9 +59,19 @@ func init() {
copyStandardLogTo("INFO")
}

var ignoredLogMessagesRe = regexp.MustCompile(
// The HTTP package complains when a client opens a TCP connection
// and immediately closes it. We don't care.
`^net/http.*:\d+\: http: TLS handshake error from .*: EOF\s*$`,
)

// Write parses the standard logging line and passes its components to the
// logger for Severity(lb).
func (lb logBridge) Write(b []byte) (n int, err error) {
if ignoredLogMessagesRe.Match(b) {
return len(b), nil
}

entry := MakeEntry(context.Background(),
Severity(lb), &mainLog.logCounter, 0, /* depth */
// Note: because the caller is using the stdLog interface, they are
Expand Down

0 comments on commit 0f0ad1d

Please sign in to comment.