Skip to content

fix: improve logging for http-connect mode #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions pkg/server/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
connected: connected,
start: time.Now(),
backend: backend,
dialID: random,
agentID: backend.GetAgentID(),
}
t.Server.PendingDial.Add(random, connection)
if err := backend.Send(dialRequest); err != nil {
klog.ErrorS(err, "failed to tunnel dial request")
klog.ErrorS(err, "failed to tunnel dial request", "host", r.Host, "dialID", connection.dialID, "agentID", connection.agentID)
return
}
ctxt := backend.Context()
Expand Down Expand Up @@ -142,22 +144,22 @@ func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
conn.Close()
}()

klog.V(3).InfoS("Starting proxy to host", "host", r.Host)
pkt := make([]byte, 1<<15) // Match GRPC Window size

connID := connection.connectID
agentID := connection.agentID
klog.V(3).InfoS("Starting proxy to host", "host", r.Host, "agentID", agentID, "connectionID", connID)

pkt := make([]byte, 1<<15) // Match GRPC Window size
var acc int

for {
n, err := bufrw.Read(pkt[:])
acc += n
if err == io.EOF {
klog.V(1).InfoS("EOF from host", "host", r.Host)
klog.V(1).InfoS("EOF from host", "host", r.Host, "agentID", agentID, "connectionID", connID)
break
}
if err != nil {
klog.ErrorS(err, "Received failure on connection")
klog.ErrorS(err, "Received failure on connection", "host", r.Host, "agentID", agentID, "connectionID", connID)
break
}

Expand All @@ -172,7 +174,7 @@ func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
err = backend.Send(packet)
if err != nil {
klog.ErrorS(err, "error sending packet")
klog.ErrorS(err, "error sending packet", "host", r.Host, "agentID", agentID, "connectionID", connID)
break
}
klog.V(5).InfoS("Forwarding data on tunnel to agent",
Expand Down