@@ -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" , "serverID" , a .serverID , "agentID" , a .agentID , "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 (4 ).InfoS ("received EOF; connection already closed" , "connectionID" , connID , "dialID" , dialReq .Random , "err" , err )
418+ } else if _ , ok := a .connManager .Get (connID ); ! ok {
419+ klog .V (5 ).InfoS ("connection already closed" , "connectionID" , connID , "dialID" , dialReq .Random , "err" , err )
420+ } else {
421+ klog .ErrorS (err , "close response failure" , "connectionID" , connID , "dialID" , dialReq .Random )
422+ }
411423 }
412424 close (dataCh )
413425 a .connManager .Delete (connID )
0 commit comments