From daf7e0350a77ae2866ef193c8c64c4328d281d02 Mon Sep 17 00:00:00 2001 From: Sergey Kacheev Date: Thu, 22 Jul 2021 23:15:20 +0700 Subject: [PATCH] etcdserver: remove code duplication from the peer.send func During the refactoring process, duplicate logging of the send buffer overflow event was added. Each of these log lines logs exactly the same information, the logging context is sufficient to distinguish the cause. Additionally, the unnecessary context (in parentheses) in the log message was removed, which was necessary without the zap context (with the old logger), but now only confuses. --- server/etcdserver/api/rafthttp/peer.go | 34 ++++++++------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/server/etcdserver/api/rafthttp/peer.go b/server/etcdserver/api/rafthttp/peer.go index 444d6bde9..c2f79e08a 100644 --- a/server/etcdserver/api/rafthttp/peer.go +++ b/server/etcdserver/api/rafthttp/peer.go @@ -250,30 +250,16 @@ func (p *peer) send(m raftpb.Message) { if isMsgSnap(m) { p.r.ReportSnapshot(m.To, raft.SnapshotFailure) } - if p.status.isActive() { - if p.lg != nil { - p.lg.Warn( - "dropped internal Raft message since sending buffer is full (overloaded network)", - zap.String("message-type", m.Type.String()), - zap.String("local-member-id", p.localID.String()), - zap.String("from", types.ID(m.From).String()), - zap.String("remote-peer-id", p.id.String()), - zap.String("remote-peer-name", name), - zap.Bool("remote-peer-active", p.status.isActive()), - ) - } - } else { - if p.lg != nil { - p.lg.Warn( - "dropped internal Raft message since sending buffer is full (overloaded network)", - zap.String("message-type", m.Type.String()), - zap.String("local-member-id", p.localID.String()), - zap.String("from", types.ID(m.From).String()), - zap.String("remote-peer-id", p.id.String()), - zap.String("remote-peer-name", name), - zap.Bool("remote-peer-active", p.status.isActive()), - ) - } + if p.lg != nil { + p.lg.Warn( + "dropped internal Raft message since sending buffer is full", + zap.String("message-type", m.Type.String()), + zap.String("local-member-id", p.localID.String()), + zap.String("from", types.ID(m.From).String()), + zap.String("remote-peer-id", p.id.String()), + zap.String("remote-peer-name", name), + zap.Bool("remote-peer-active", p.status.isActive()), + ) } sentFailures.WithLabelValues(types.ID(m.To).String()).Inc() }