app/vminsert: do not pollute logs with repated cannot dial storageNode errors

Log only the first error per -storageNode
This commit is contained in:
Aliaksandr Valialkin 2020-09-29 00:20:01 +03:00
parent 0548f0c5c8
commit bc37f1cbec

View file

@ -199,10 +199,15 @@ func (sn *storageNode) checkHealth() {
}
bc, err := sn.dial()
if err != nil {
logger.Warnf("cannot dial storageNode %q: %s", sn.dialer.Addr(), err)
if sn.lastDialErr == nil {
// Log the error only once.
sn.lastDialErr = err
logger.Warnf("cannot dial storageNode %q: %s", sn.dialer.Addr(), err)
}
return
}
logger.Infof("successfully dialed -storageNode=%q", sn.dialer.Addr())
sn.lastDialErr = nil
sn.bc = bc
atomic.StoreUint32(&sn.broken, 0)
}
@ -371,6 +376,9 @@ type storageNode struct {
dialer *netutil.TCPDialer
// last error during dial.
lastDialErr error
// The number of dial errors to vmstorage node.
dialErrors *metrics.Counter