diff --git a/command/agent/config.go b/command/agent/config.go index f56e3e740f..6e74d0294f 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -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 } diff --git a/command/agent/dns.go b/command/agent/dns.go index a50486173e..8d5d197bd7 100644 --- a/command/agent/dns.go +++ b/command/agent/dns.go @@ -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 + } } }