Skip to content

Commit

Permalink
runtime: skip logging some of the dial errors
Browse files Browse the repository at this point in the history
With full debug logging enabled there might be around 1,500 redials
so skip logging some of these failures to avoid flooding the log.

Signed-off-by: Dan Mihai <[email protected]>
  • Loading branch information
danmihai1 committed Nov 14, 2024
1 parent bc69b85 commit 5c6d793
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/runtime/virtcontainers/pkg/agent/protocols/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const (
var defaultDialTimeout = 30 * time.Second

var hybridVSockPort uint32
var hybridVSockErrors uint32 = 0

const hybridVSockErrorsSkip uint32 = 128

var agentClientFields = logrus.Fields{
"name": "agent-client",
Expand Down Expand Up @@ -425,9 +428,16 @@ func HybridVSockDialer(sock string, timeout time.Duration) (net.Conn, error) {
case err = <-errChan:
if err != nil {
conn.Close()
agentClientLog.WithField("Error", err).Debug("HybridVsock trivial handshake failed")
return nil, err

// With full debug logging enabled there might be around 1,500 redials in a tight loop, so
// skip logging some of these failures to avoid flooding the log.
errorsCount := hybridVSockErrors
if errorsCount%hybridVSockErrorsSkip == 0 {
agentClientLog.WithField("Error", err).WithField("count", errorsCount).Debug("HybridVsock trivial handshake failed")
}
hybridVSockErrors = errorsCount + 1

return nil, err
}
return conn, nil
case <-time.After(handshakeTimeout):
Expand Down

0 comments on commit 5c6d793

Please sign in to comment.