Skip to content

Commit

Permalink
When an error occurs, log the IP address of the far end.
Browse files Browse the repository at this point in the history
Summary:
Example of a current error message:
```
2024/10/11 06:21:10 thrift: error processing request: tls: first record does not look like a TLS handshake
```

It does not include any information about the connection source making it impossible to determine the source of the problem.

This patch adds the RemoteAddress() to the message to provide information about the source of the reqest that generated the error.

Reviewed By: awalterschulze

Differential Revision: D64241912

fbshipit-source-id: 70ee77ac6016f3d939e31c7d1c154f1f1ba2616f
  • Loading branch information
Leo Bicknell authored and facebook-github-bot committed Oct 11, 2024
1 parent f76953c commit 45fcc14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion thrift/lib/go/thrift/header_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (p *headerServer) acceptLoop(ctx context.Context) error {
go func(ctx context.Context, conn net.Conn) {
ctx = p.connContext(ctx, conn)
if err := p.processRequests(ctx, conn); err != nil {
p.log.Println("thrift: error processing request:", err)
p.log.Printf("error processing request from %s: %s", conn.RemoteAddr().String(), err)
}
}(ctx, conn)
}
Expand Down
10 changes: 5 additions & 5 deletions thrift/lib/go/thrift/rocket_server_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,28 +107,28 @@ func (r *rocketServerTransport) processRequests(ctx context.Context, conn net.Co
processor := newRocketUpgradeProcessor(r.processor)
headerProtocol, err := NewHeaderProtocol(conn)
if err != nil {
r.log.Println("thrift: error constructing header protocol: ", err)
r.log.Printf("thrift: error constructing header protocol from %s: %s", conn.RemoteAddr().String(), err)
return
}
if err := r.processHeaderRequest(ctx, headerProtocol, processor); err != nil {
r.log.Println("thrift: error processing request: ", err)
r.log.Printf("thrift: error processing request from %s: %s", conn.RemoteAddr().String(), err)
return
}
if processor.upgraded {
r.processRocketRequests(ctx, conn)
} else {
if err := r.processHeaderRequests(ctx, headerProtocol, processor); err != nil {
r.log.Println("thrift: error processing request: ", err)
r.log.Printf("thrift: error processing request from %s: %s", conn.RemoteAddr().String(), err)
}
}
case TransportIDHeader:
headerProtocol, err := NewHeaderProtocol(conn)
if err != nil {
r.log.Println("thrift: error constructing header protocol: ", err)
r.log.Printf("thrift: error constructing header protocol from %s: %s", conn.RemoteAddr().String(), err)
return
}
if err := r.processHeaderRequests(ctx, headerProtocol, r.processor); err != nil {
r.log.Println("thrift: error processing request: ", err)
r.log.Printf("thrift: error processing request from %s: %s", conn.RemoteAddr().String(), err)
}
}
}
Expand Down

0 comments on commit 45fcc14

Please sign in to comment.