Merge pull request #722 from erikwilson/debug-lb-logs

Change load balancer logging to debug
pull/729/head
Erik Wilson 2019-08-09 14:12:31 -07:00 committed by GitHub
commit c849525a27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -75,6 +75,7 @@ func Setup(ctx context.Context, cfg cmds.Agent) (_lb *LoadBalancer, _err error)
lb.proxy.AddRoute(serviceName, &tcpproxy.DialProxy{
Addr: serviceName,
DialContext: lb.dialContext,
OnDialError: onDialError,
})
if err := lb.updateConfig(); err != nil {
@ -118,14 +119,14 @@ func (lb *LoadBalancer) dialContext(ctx context.Context, network, address string
if err == nil {
return conn, nil
}
logrus.Warnf("Dial error from load balancer: %s", err)
logrus.Debugf("Dial error from load balancer: %s", err)
newServer, err := lb.nextServer(targetServer)
if err != nil {
return nil, err
}
if targetServer != newServer {
logrus.Warnf("Dial context in load balancer failed over to %s", newServer)
logrus.Debugf("Dial server in load balancer failed over to %s", newServer)
}
if ctx.Err() != nil {
return nil, ctx.Err()
@ -140,3 +141,8 @@ func (lb *LoadBalancer) dialContext(ctx context.Context, network, address string
}
}
}
func onDialError(src net.Conn, dstDialErr error) {
logrus.Debugf("Incoming conn %v, error dialing load balancer servers: %v", src.RemoteAddr().String(), dstDialErr)
src.Close()
}