Skip to content

Commit

Permalink
Merge pull request #329 from andrewsykim/proxy-server-improve-logging
Browse files Browse the repository at this point in the history
Fix misleading log messages in proxy server when sending DIAL_REQ and CLOSE_REQ
  • Loading branch information
k8s-ci-robot authored Mar 3, 2022
2 parents c638569 + 09206ec commit 2dae7c8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,13 +429,14 @@ func (s *ProxyServer) serveRecvFrontend(stream client.ProxyService_ProxyServer,
Payload: &client.Packet_DialResponse{DialResponse: &client.DialResponse{Error: err.Error()}},
}
if err := stream.Send(resp); err != nil {
klog.V(5).Infoln("Failed to send DIAL_RSP for no backend", "error", err, "serverID", s.serverID)
klog.V(5).InfoS("Failed to send DIAL_RSP for no backend", "error", err, "serverID", s.serverID)
}
// The Dial is failing; no reason to keep this goroutine.
return
}
random := pkt.GetDialRequest().Random
s.PendingDial.Add(
pkt.GetDialRequest().Random,
random,
&ProxyClientConnection{
Mode: "grpc",
Grpc: stream,
Expand All @@ -444,9 +445,10 @@ func (s *ProxyServer) serveRecvFrontend(stream client.ProxyService_ProxyServer,
backend: backend,
})
if err := backend.Send(pkt); err != nil {
klog.ErrorS(err, "DIAL_REQ to Backend failed", "serverID", s.serverID)
klog.ErrorS(err, "DIAL_REQ to Backend failed", "serverID", s.serverID, "dialID", random)
} else {
klog.V(5).InfoS("DIAL_REQ sent to backend", "serverID", s.serverID, "dialID", random)
}
klog.V(5).Infoln("DIAL_REQ sent to backend") // got this. but backend didn't receive anything.

case client.PacketType_CLOSE_REQ:
connID := pkt.GetCloseRequest().ConnectID
Expand All @@ -459,15 +461,16 @@ func (s *ProxyServer) serveRecvFrontend(stream client.ProxyService_ProxyServer,
if err := backend.Send(pkt); err != nil {
// TODO: retry with other backends connecting to this agent.
klog.ErrorS(err, "CLOSE_REQ to Backend failed", "serverID", s.serverID, "connectionID", connID)
} else {
klog.V(5).InfoS("CLOSE_REQ sent to backend", "serverID", s.serverID, "connectionID", connID)
}
klog.V(5).Infoln("CLOSE_REQ sent to backend", "serverID", s.serverID, "connectionID", connID)

case client.PacketType_DIAL_CLS:
random := pkt.GetCloseDial().Random
klog.V(5).InfoS("Received DIAL_CLOSE", "serverID", s.serverID, "dialID", random)
// Currently not worrying about backend as we do not have an established connection,
s.PendingDial.Remove(random)
klog.V(5).Infoln("Removing pending dial request", "serverID", s.serverID, "dialID", random)
klog.V(5).InfoS("Removing pending dial request", "serverID", s.serverID, "dialID", random)

case client.PacketType_DATA:
connID := pkt.GetData().ConnectID
Expand Down Expand Up @@ -714,7 +717,7 @@ func (s *ProxyServer) serveRecvBackend(backend Backend, stream agent.AgentServic
klog.V(5).InfoS("Received DIAL_RSP", "dialID", resp.Random, "agentID", agentID, "connectionID", resp.ConnectID)

if frontend, ok := s.PendingDial.Get(resp.Random); !ok {
klog.V(2).Infoln("DIAL_RSP not recognized; dropped", "dialID", resp.Random, "agentID", agentID, "connectionID", resp.ConnectID)
klog.V(2).InfoS("DIAL_RSP not recognized; dropped", "dialID", resp.Random, "agentID", agentID, "connectionID", resp.ConnectID)
} else {
dialErr := false
if resp.Error != "" {
Expand Down Expand Up @@ -765,7 +768,7 @@ func (s *ProxyServer) serveRecvBackend(backend Backend, stream agent.AgentServic
// Normal when frontend closes it.
klog.ErrorS(err, "CLOSE_RSP send to client stream error", "serverID", s.serverID, "agentID", agentID, "connectionID", resp.ConnectID)
} else {
klog.V(5).Infoln("CLOSE_RSP sent to frontend", "connectionID", resp.ConnectID)
klog.V(5).InfoS("CLOSE_RSP sent to frontend", "connectionID", resp.ConnectID)
}
s.removeFrontend(agentID, resp.ConnectID)
klog.V(5).InfoS("Close streaming", "agentID", agentID, "connectionID", resp.ConnectID)
Expand Down

0 comments on commit 2dae7c8

Please sign in to comment.