Renamed dns config parameter internal_client_timeout for recursor_timeout

pull/2321/head
Pierre Delagrave 8 years ago
parent 3fe117c24d
commit d9bd41fc4d

@ -103,19 +103,19 @@ type DNSConfig struct {
// OnlyPassing is used to determine whether to filter nodes
// whose health checks are in any non-passing state. By
// default, only nodes in a critical state are excluded.
OnlyPassing bool `mapstructure:"only_passing"`
OnlyPassing bool `mapstructure:"only_passing"`
// DisableCompression is used to control whether DNS responses are
// compressed. In Consul 0.7 this was turned on by default and this
// config was added as an opt-out.
DisableCompression bool `mapstructure:"disable_compression"`
// InternalClientTimeout specifies the timeout in seconds
// for Consul's internal dns client. This value is used for the
// connection, read and write timeout.
// RecursorTimeout specifies the timeout in seconds
// for Consul's internal dns client used for recursion.
// This value is used for the connection, read and write timeout.
// Default: 2s
InternalClientTimeout time.Duration `mapstructure:"-"`
InternalClientTimeoutRaw string `mapstructure:"internal_client_timeout" json:"-"`
RecursorTimeout time.Duration `mapstructure:"-"`
RecursorTimeoutRaw string `mapstructure:"recursor_timeout" json:"-"`
}
// Performance is used to tune the performance of Consul's subsystems.
@ -653,7 +653,7 @@ func DefaultConfig() *Config {
DNSConfig: DNSConfig{
UDPAnswerLimit: 3,
MaxStale: 5 * time.Second,
InternalClientTimeout: 2 * time.Second,
RecursorTimeout: 2 * time.Second,
},
Telemetry: Telemetry{
StatsitePrefix: "consul",
@ -846,12 +846,12 @@ func DecodeConfig(r io.Reader) (*Config, error) {
result.DNSConfig.MaxStale = dur
}
if raw := result.DNSConfig.InternalClientTimeoutRaw; raw != "" {
if raw := result.DNSConfig.RecursorTimeoutRaw; raw != "" {
dur, err := time.ParseDuration(raw)
if err != nil {
return nil, fmt.Errorf("InternalClientTimeout invalid: %v", err)
return nil, fmt.Errorf("RecursorTimeout invalid: %v", err)
}
result.DNSConfig.InternalClientTimeout = dur
result.DNSConfig.RecursorTimeout = dur
}
if len(result.DNSConfig.ServiceTTLRaw) != 0 {
@ -1369,8 +1369,8 @@ func MergeConfig(a, b *Config) *Config {
if b.DNSConfig.DisableCompression {
result.DNSConfig.DisableCompression = true
}
if b.DNSConfig.InternalClientTimeout != 0 {
result.DNSConfig.InternalClientTimeout = b.DNSConfig.InternalClientTimeout
if b.DNSConfig.RecursorTimeout != 0 {
result.DNSConfig.RecursorTimeout = b.DNSConfig.RecursorTimeout
}
if b.CheckUpdateIntervalRaw != "" || b.CheckUpdateInterval != 0 {
result.CheckUpdateInterval = b.CheckUpdateInterval

@ -544,7 +544,7 @@ func TestDecodeConfig(t *testing.T) {
}
// DNS node ttl, max stale
input = `{"dns_config": {"allow_stale": true, "enable_truncate": false, "max_stale": "15s", "node_ttl": "5s", "only_passing": true, "udp_answer_limit": 6, "internal_client_timeout": "7s"}}`
input = `{"dns_config": {"allow_stale": true, "enable_truncate": false, "max_stale": "15s", "node_ttl": "5s", "only_passing": true, "udp_answer_limit": 6, "recursor_timeout": "7s"}}`
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
if err != nil {
t.Fatalf("err: %s", err)
@ -568,7 +568,7 @@ func TestDecodeConfig(t *testing.T) {
if config.DNSConfig.UDPAnswerLimit != 6 {
t.Fatalf("bad: %#v", config)
}
if config.DNSConfig.InternalClientTimeout != 7*time.Second {
if config.DNSConfig.RecursorTimeout != 7*time.Second {
t.Fatalf("bad: %#v", config)
}

@ -842,7 +842,7 @@ func (d *DNSServer) handleRecurse(resp dns.ResponseWriter, req *dns.Msg) {
}
// Recursively resolve
c := &dns.Client{Net: network, Timeout: d.config.InternalClientTimeout}
c := &dns.Client{Net: network, Timeout: d.config.RecursorTimeout}
var r *dns.Msg
var rtt time.Duration
var err error
@ -887,7 +887,7 @@ func (d *DNSServer) resolveCNAME(name string) []dns.RR {
m.SetQuestion(name, dns.TypeA)
// Make a DNS lookup request
c := &dns.Client{Net: "udp", Timeout: d.config.InternalClientTimeout}
c := &dns.Client{Net: "udp", Timeout: d.config.RecursorTimeout}
var r *dns.Msg
var rtt time.Duration
var err error

@ -1400,14 +1400,14 @@ func TestDNS_Recurse(t *testing.T) {
}
}
func TestDNS_InternalClientTimeout(t *testing.T) {
func TestDNS_RecursorTimeout(t *testing.T) {
serverClientTimeout := 3 * time.Second
testClientTimeout := serverClientTimeout + 5*time.Second
dir, srv := makeDNSServerConfig(t, func(c *Config) {
c.DNSRecursor = "127.0.0.77" // must be an unreachable host
}, func(c *DNSConfig) {
c.InternalClientTimeout = serverClientTimeout
c.RecursorTimeout = serverClientTimeout
})
defer os.RemoveAll(dir)
defer srv.agent.Shutdown()

Loading…
Cancel
Save