Renamed dns config parameter internal_client_timeout for recursor_timeout

This commit is contained in:
Pierre Delagrave 2016-08-26 15:22:04 -04:00
parent 3fe117c24d
commit d9bd41fc4d
4 changed files with 18 additions and 18 deletions

View File

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

View File

@ -544,7 +544,7 @@ func TestDecodeConfig(t *testing.T) {
} }
// DNS node ttl, max stale // 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))) config, err = DecodeConfig(bytes.NewReader([]byte(input)))
if err != nil { if err != nil {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
@ -568,7 +568,7 @@ func TestDecodeConfig(t *testing.T) {
if config.DNSConfig.UDPAnswerLimit != 6 { if config.DNSConfig.UDPAnswerLimit != 6 {
t.Fatalf("bad: %#v", config) t.Fatalf("bad: %#v", config)
} }
if config.DNSConfig.InternalClientTimeout != 7*time.Second { if config.DNSConfig.RecursorTimeout != 7*time.Second {
t.Fatalf("bad: %#v", config) t.Fatalf("bad: %#v", config)
} }

View File

@ -842,7 +842,7 @@ func (d *DNSServer) handleRecurse(resp dns.ResponseWriter, req *dns.Msg) {
} }
// Recursively resolve // 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 r *dns.Msg
var rtt time.Duration var rtt time.Duration
var err error var err error
@ -887,7 +887,7 @@ func (d *DNSServer) resolveCNAME(name string) []dns.RR {
m.SetQuestion(name, dns.TypeA) m.SetQuestion(name, dns.TypeA)
// Make a DNS lookup request // 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 r *dns.Msg
var rtt time.Duration var rtt time.Duration
var err error var err error

View File

@ -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 serverClientTimeout := 3 * time.Second
testClientTimeout := serverClientTimeout + 5*time.Second testClientTimeout := serverClientTimeout + 5*time.Second
dir, srv := makeDNSServerConfig(t, func(c *Config) { dir, srv := makeDNSServerConfig(t, func(c *Config) {
c.DNSRecursor = "127.0.0.77" // must be an unreachable host c.DNSRecursor = "127.0.0.77" // must be an unreachable host
}, func(c *DNSConfig) { }, func(c *DNSConfig) {
c.InternalClientTimeout = serverClientTimeout c.RecursorTimeout = serverClientTimeout
}) })
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
defer srv.agent.Shutdown() defer srv.agent.Shutdown()