From 1fbc1d4777d26ba944e7755234db942fad276ff5 Mon Sep 17 00:00:00 2001 From: Hans Hasselberg Date: Thu, 28 May 2020 10:56:10 +0200 Subject: [PATCH] pool: remove timeout parameter Timeout was never used in a meaningful way by callers, which is why it is now entirely internal to the pool. --- agent/consul/snapshot_endpoint.go | 2 +- agent/pool/pool.go | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/agent/consul/snapshot_endpoint.go b/agent/consul/snapshot_endpoint.go index 5f6e3e0f8dba..fb2f581d801f 100644 --- a/agent/consul/snapshot_endpoint.go +++ b/agent/consul/snapshot_endpoint.go @@ -200,7 +200,7 @@ func SnapshotRPC( ) (io.ReadCloser, error) { // Write the snapshot RPC byte to set the mode, then perform the // request. - conn, hc, err := connPool.DialTimeout(dc, nodeName, addr, 10*time.Second, pool.RPCSnapshot) + conn, hc, err := connPool.DialTimeout(dc, nodeName, addr, pool.RPCSnapshot) if err != nil { return nil, err } diff --git a/agent/pool/pool.go b/agent/pool/pool.go index 6255f4f4e43b..7f14faa38e27 100644 --- a/agent/pool/pool.go +++ b/agent/pool/pool.go @@ -286,7 +286,6 @@ func (p *ConnPool) DialTimeout( dc string, nodeName string, addr net.Addr, - timeout time.Duration, actualRPCType RPCType, ) (net.Conn, HalfCloser, error) { p.once.Do(p.init) @@ -298,7 +297,6 @@ func (p *ConnPool) DialTimeout( nodeName, addr, p.SrcAddr, - timeout, p.TLSConfigurator.OutgoingALPNRPCWrapper(), actualRPCType, RPCTLS, @@ -314,7 +312,6 @@ func (p *ConnPool) DialTimeout( dc, nodeName, addr, - timeout, actualRPCType, RPCTLS, ) @@ -324,12 +321,11 @@ func (p *ConnPool) dial( dc string, nodeName string, addr net.Addr, - timeout time.Duration, actualRPCType RPCType, tlsRPCType RPCType, ) (net.Conn, HalfCloser, error) { // Try to dial the conn - d := &net.Dialer{LocalAddr: p.SrcAddr, Timeout: timeout} + d := &net.Dialer{LocalAddr: p.SrcAddr, Timeout: defaultDialTimeout} conn, err := d.Dial("tcp", addr.String()) if err != nil { return nil, nil, err @@ -393,7 +389,6 @@ func DialTimeoutWithRPCTypeViaMeshGateway( nodeName string, addr net.Addr, src *net.TCPAddr, - timeout time.Duration, wrapper tlsutil.ALPNWrapper, actualRPCType RPCType, tlsRPCType RPCType, @@ -425,7 +420,7 @@ func DialTimeoutWithRPCTypeViaMeshGateway( return nil, nil, structs.ErrDCNotAvailable } - dialer := &net.Dialer{LocalAddr: src, Timeout: timeout} + dialer := &net.Dialer{LocalAddr: src, Timeout: defaultDialTimeout} rawConn, err := dialer.Dial("tcp", gwAddr) if err != nil { @@ -461,7 +456,7 @@ func (p *ConnPool) getNewConn(dc string, nodeName string, addr net.Addr) (*Conn, } // Get a new, raw connection and write the Consul multiplex byte to set the mode - conn, _, err := p.DialTimeout(dc, nodeName, addr, defaultDialTimeout, RPCMultiplexV2) + conn, _, err := p.DialTimeout(dc, nodeName, addr, RPCMultiplexV2) if err != nil { return nil, err } @@ -575,7 +570,7 @@ func (p *ConnPool) rpcInsecure(dc string, nodeName string, addr net.Addr, method } var codec rpc.ClientCodec - conn, _, err := p.dial(dc, nodeName, addr, 1*time.Second, 0, RPCTLSInsecure) + conn, _, err := p.dial(dc, nodeName, addr, 0, RPCTLSInsecure) if err != nil { return fmt.Errorf("rpcinsecure error establishing connection: %v", err) }