Skip to content
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

Update default transport configurations #164

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var (
DialTimeout: TimeDuration(10 * time.Second),
DisableKeepAlives: Bool(false),
IdleConnTimeout: TimeDuration(1 * time.Minute),
MaxIdleConnsPerHost: Int(5),
MaxIdleConnsPerHost: Int(100),
TLSHandshakeTimeout: TimeDuration(10 * time.Second),
},
},
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestConfig_Finalize(t *testing.T) {
expected.BufferPeriod.Enabled = Bool(true)
expected.Consul.KVNamespace = String("")
expected.Consul.TLS.Cert = String("")
expected.Consul.Transport.MaxIdleConns = Int(100)
expected.Consul.Transport.MaxIdleConns = Int(0)
expected.Vault = DefaultVaultConfig()
expected.Vault.Finalize()
expected.Driver.consul = expected.Consul
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/long.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ consul {
dial_timeout = "10s"
disable_keep_alives = false
idle_conn_timeout = "1m"
max_idle_conns_per_host = 5
max_idle_conns_per_host = 100
tls_handshake_timeout = "10s"
}
}
Expand Down
2 changes: 1 addition & 1 deletion config/testdata/long.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dial_timeout": "10s",
"disable_keep_alives": false,
"idle_conn_timeout": "1m",
"max_idle_conns_per_host": 5,
"max_idle_conns_per_host": 100,
"tls_handshake_timeout": "10s"
}
},
Expand Down
33 changes: 24 additions & 9 deletions config/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"fmt"
"runtime"
"time"
)

Expand All @@ -17,22 +16,20 @@ const (

// DefaultIdleConnTimeout is the default connection timeout for idle
// connections.
DefaultIdleConnTimeout = 90 * time.Second
DefaultIdleConnTimeout = 5 * time.Second

// DefaultMaxIdleConns is the default number of maximum idle connections.
DefaultMaxIdleConns = 100
DefaultMaxIdleConns = 0

// DefaultMaxIdleConnsPerHost is the default number of maximum idle
// connections per host.
DefaultMaxIdleConnsPerHost = 100

// DefaultTLSHandshakeTimeout is the amount of time to negotiate the TLS
// handshake.
DefaultTLSHandshakeTimeout = 10 * time.Second
)

var (
// DefaultMaxIdleConnsPerHost is the default number of idle connections to use
// per host.
DefaultMaxIdleConnsPerHost = runtime.GOMAXPROCS(0) + 1
)

// TransportConfig is the configuration to tune low-level APIs for the
// interactions on the wire.
type TransportConfig struct {
Expand All @@ -54,6 +51,20 @@ type TransportConfig struct {

// MaxIdleConnsPerHost is the maximum number of idle connections per remote
// host.
//
// The majority of connections are established with one host, the Consul agent.
// To achieve the shortest latency between a Consul service update to a task
// execution, configure the max_idle_conns_per_host to a number proportional to
// the number of services in automation across all tasks.
//
// This value must be lower than the configured http_max_conns_per_client
// for the Consul agent. Note that requests made by Terraform subprocesses
// or any other process on the same host as Consul-Terraform-Sync will
// contribute to the Consul agent http_max_conns_per_client.
//
// If max_idle_conns_per_host or the number of services in automation is greater
// than the Consul agent limit, Consul-Terraform-Sync may error due to
// connection limits (429).
MaxIdleConnsPerHost *int `mapstructure:"max_idle_conns_per_host"`

// TLSHandshakeTimeout is the amount of time to wait to complete the TLS
Expand Down Expand Up @@ -176,12 +187,16 @@ func (c *TransportConfig) GoString() string {
"DialKeepAlive:%s, "+
"DialTimeout:%s, "+
"DisableKeepAlives:%t, "+
"IdleConnTimeout:%d, "+
"MaxIdleConns:%d, "+
"MaxIdleConnsPerHost:%d, "+
"TLSHandshakeTimeout:%s"+
"}",
TimeDurationVal(c.DialKeepAlive),
TimeDurationVal(c.DialTimeout),
BoolVal(c.DisableKeepAlives),
TimeDurationVal(c.IdleConnTimeout),
IntVal(c.MaxIdleConns),
IntVal(c.MaxIdleConnsPerHost),
TimeDurationVal(c.TLSHandshakeTimeout),
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,6 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/hcat v0.0.0-20201102235459-09d8cd851630 h1:G2tn+rLFEtxN+2Ibk3vDZ+7Kxc+VtNOg9Lu8v6URr6o=
github.com/hashicorp/hcat v0.0.0-20201102235459-09d8cd851630/go.mod h1:EdfFuaZdeoDhNpqom+ZqaDhw6dX/gtK2JEFgUPyCcZc=
github.com/hashicorp/hcat v0.0.0-20201211001333-cc9b9b904d72 h1:U69JSA5apZmu/N9luM/sJtFYWJIzEVavIvBOomeDaIg=
github.com/hashicorp/hcat v0.0.0-20201211001333-cc9b9b904d72/go.mod h1:EdfFuaZdeoDhNpqom+ZqaDhw6dX/gtK2JEFgUPyCcZc=
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
Expand Down