Skip to content

Commit

Permalink
Quiet more error logs on stream canceled.
Browse files Browse the repository at this point in the history
This is a complaint at kubernetes-sigs#358

Note that this extends an existing pattern.
  • Loading branch information
jkh52 committed May 31, 2023
1 parent fd446dc commit 4a1ebcb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pkg/agent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"k8s.io/klog/v2"

commonmetrics "sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/common/metrics"
Expand Down Expand Up @@ -332,7 +334,11 @@ func (a *Client) Serve() {
klog.V(2).InfoS("received EOF, exit", "serverID", a.serverID, "agentID", a.agentID)
return
}
klog.ErrorS(err, "could not read stream", "serverID", a.serverID, "agentID", a.agentID)
if status.Code(err) == codes.Canceled {
klog.V(2).InfoS("stream canceled", "serverID", a.serverID, "agentID", a.agentID)
} else {
klog.ErrorS(err, "could not read stream", "serverID", a.serverID, "agentID", a.agentID)
}
return
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,11 @@ func (s *ProxyServer) readBackendToChannel(backend Backend, recvCh chan *client.
return
}
if err != nil {
klog.ErrorS(err, "Receive stream from agent read failure")
if status.Code(err) == codes.Canceled {
klog.V(2).InfoS("Stream read from agent cancelled", "agentID", agentID)
} else {
klog.ErrorS(err, "Receive stream from agent read failure", "agentID", agentID)
}
stopCh <- err
close(stopCh)
return
Expand Down

0 comments on commit 4a1ebcb

Please sign in to comment.