From 4a1ebcb8f3ba71e82640a508bbe3681eda619e99 Mon Sep 17 00:00:00 2001 From: Joseph Anttila Hall Date: Wed, 31 May 2023 13:31:18 -0700 Subject: [PATCH] Quiet more error logs on stream canceled. This is a complaint at https://github.com/kubernetes-sigs/apiserver-network-proxy/issues/358 Note that this extends an existing pattern. --- pkg/agent/client.go | 8 +++++++- pkg/server/server.go | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/agent/client.go b/pkg/agent/client.go index 90afa5f10..135bc9248 100644 --- a/pkg/agent/client.go +++ b/pkg/agent/client.go @@ -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" @@ -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 } diff --git a/pkg/server/server.go b/pkg/server/server.go index dc5599f55..3e119803c 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -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