Skip to content

Commit 2fa9dd1

Browse files
committed
Stopping logging error when the connection no longer exists
1 parent b07cd6d commit 2fa9dd1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pkg/agent/client.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,13 @@ func (a *Client) Serve() {
354354
if status.Code(err) == codes.Canceled {
355355
klog.V(2).InfoS("stream canceled", "serverID", a.serverID, "agentID", a.agentID)
356356
} else {
357-
klog.ErrorS(err, "could not read stream", "serverID", a.serverID, "agentID", a.agentID)
357+
select {
358+
case <-a.stopCh:
359+
klog.V(5).InfoS("could not read stream because agent client is shutting down", "err", err)
360+
default:
361+
// If stopCh is not closed, this is a legitimate, unexpected error.
362+
klog.ErrorS(err, "could not read stream", "serverID", a.serverID, "agentID", a.agentID)
363+
}
358364
}
359365
return
360366
}
@@ -407,7 +413,13 @@ func (a *Client) Serve() {
407413
closePkt.GetCloseResponse().ConnectID = connID
408414
}
409415
if err := a.Send(closePkt); err != nil {
410-
klog.ErrorS(err, "close response failure", "")
416+
if err == io.EOF {
417+
klog.V(2).InfoS("received EOF; connection already closed", "connectionID", connID, "err", err)
418+
} else if _, ok := a.connManager.Get(connID); !ok {
419+
klog.V(5).InfoS("connection already closed", "connectionID", connID, "err", err)
420+
} else {
421+
klog.ErrorS(err, "close response failure", "")
422+
}
411423
}
412424
close(dataCh)
413425
a.connManager.Delete(connID)

0 commit comments

Comments
 (0)