avoid excessive logs when peer is down (#18969)

This commit is contained in:
Harshavardhana
2024-02-04 23:25:42 -08:00
committed by GitHub
parent 8414aff424
commit 100c35c281
2 changed files with 12 additions and 13 deletions

View File

@@ -30,7 +30,6 @@ import (
"net"
"net/http"
"runtime/debug"
"strconv"
"strings"
"sync"
"sync/atomic"
@@ -661,8 +660,7 @@ func (c *Connection) connect() {
if gotState != StateConnecting {
// Don't print error on first attempt,
// and after that only once per hour.
cHour := strconv.FormatInt(time.Now().Unix()/60/60, 10)
logger.LogOnceIf(c.ctx, fmt.Errorf("grid: %s connecting to %s: %w (%T) Sleeping %v (%v)", c.Local, toDial, err, err, sleep, gotState), c.Local+toDial+cHour+err.Error())
logger.LogOnceIf(c.ctx, fmt.Errorf("grid: %s connecting to %s: %w (%T) Sleeping %v (%v)", c.Local, toDial, err, err, sleep, gotState), toDial)
}
c.updateState(StateConnectionError)
time.Sleep(sleep)