Adding singleton option to DNS for getaddrinfo bug.

This commit is contained in:
Patrick Feliciano 2016-01-09 06:36:38 +00:00 committed by Sean Chittenden
parent b7b46f9e3a
commit 6b665d3ddb
2 changed files with 14 additions and 0 deletions

View File

@ -77,6 +77,14 @@ type DNSConfig struct {
// returned by default for UDP.
EnableTruncate bool `mapstructure:"enable_truncate"`
// EnableSingleton is used to override default behavior
// of DNS and return only a single host in a round robin
// DNS service request rather than all healthy service
// members. This is a work around for systems using
// getaddrinfo using rule 9 sorting from RFC3484 which
// breaks round robin DNS.
EnableSingleton bool `mapstructure:"enable_singleton"`
// MaxStale is used to bound how stale of a result is
// accepted for a DNS lookup. This can be used with
// AllowStale to limit how old of a value is served up.
@ -1130,6 +1138,9 @@ func MergeConfig(a, b *Config) *Config {
if b.DNSConfig.EnableTruncate {
result.DNSConfig.EnableTruncate = true
}
if b.DNSConfig.EnableSingleton {
result.DNSConfig.EnableSingleton = true
}
if b.DNSConfig.MaxStale != 0 {
result.DNSConfig.MaxStale = b.DNSConfig.MaxStale
}

View File

@ -684,6 +684,9 @@ func (d *DNSServer) serviceNodeRecords(dc string, nodes structs.CheckServiceNode
if records != nil {
resp.Answer = append(resp.Answer, records...)
}
if d.config.EnableSingleton {
break
}
}
}