Skip to content

Commit

Permalink
Changes default DNS allow_stale to true.
Browse files Browse the repository at this point in the history
  • Loading branch information
slackpad committed Aug 30, 2016
1 parent 3effaa7 commit ed7356d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 19 deletions.
7 changes: 4 additions & 3 deletions command/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type DNSConfig struct {
// data. This gives horizontal read scalability since
// any Consul server can service the query instead of
// only the leader.
AllowStale bool `mapstructure:"allow_stale"`
AllowStale *bool `mapstructure:"allow_stale"`

// EnableTruncate is used to enable setting the truncate
// flag for UDP DNS queries. This allows unmodified
Expand Down Expand Up @@ -644,6 +644,7 @@ func DefaultConfig() *Config {
Server: 8300,
},
DNSConfig: DNSConfig{
AllowStale: Bool(true),
UDPAnswerLimit: 3,
MaxStale: 5 * time.Second,
},
Expand Down Expand Up @@ -1335,8 +1336,8 @@ func MergeConfig(a, b *Config) *Config {
result.DNSConfig.ServiceTTL[service] = dur
}
}
if b.DNSConfig.AllowStale {
result.DNSConfig.AllowStale = true
if b.DNSConfig.AllowStale != nil {
result.DNSConfig.AllowStale = b.DNSConfig.AllowStale
}
if b.DNSConfig.UDPAnswerLimit != 0 {
result.DNSConfig.UDPAnswerLimit = b.DNSConfig.UDPAnswerLimit
Expand Down
6 changes: 3 additions & 3 deletions command/agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,13 +544,13 @@ 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}}`
input = `{"dns_config": {"allow_stale": false, "enable_truncate": false, "max_stale": "15s", "node_ttl": "5s", "only_passing": true, "udp_answer_limit": 6}}`
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
if err != nil {
t.Fatalf("err: %s", err)
}

if !config.DNSConfig.AllowStale {
if *config.DNSConfig.AllowStale {
t.Fatalf("bad: %#v", config)
}
if config.DNSConfig.EnableTruncate {
Expand Down Expand Up @@ -1408,7 +1408,7 @@ func TestMergeConfig(t *testing.T) {
DataDir: "/tmp/bar",
DNSRecursors: []string{"127.0.0.2:1001"},
DNSConfig: DNSConfig{
AllowStale: false,
AllowStale: Bool(false),
EnableTruncate: true,
DisableCompression: true,
MaxStale: 30 * time.Second,
Expand Down
8 changes: 4 additions & 4 deletions command/agent/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (d *DNSServer) handlePtr(resp dns.ResponseWriter, req *dns.Msg) {
Datacenter: datacenter,
QueryOptions: structs.QueryOptions{
Token: d.agent.config.ACLToken,
AllowStale: d.config.AllowStale,
AllowStale: *d.config.AllowStale,
},
}
var out structs.IndexedNodes
Expand Down Expand Up @@ -384,7 +384,7 @@ func (d *DNSServer) nodeLookup(network, datacenter, node string, req, resp *dns.
Node: node,
QueryOptions: structs.QueryOptions{
Token: d.agent.config.ACLToken,
AllowStale: d.config.AllowStale,
AllowStale: *d.config.AllowStale,
},
}
var out structs.IndexedNodeServices
Expand Down Expand Up @@ -584,7 +584,7 @@ func (d *DNSServer) serviceLookup(network, datacenter, service, tag string, req,
TagFilter: tag != "",
QueryOptions: structs.QueryOptions{
Token: d.agent.config.ACLToken,
AllowStale: d.config.AllowStale,
AllowStale: *d.config.AllowStale,
},
}
var out structs.IndexedCheckServiceNodes
Expand Down Expand Up @@ -658,7 +658,7 @@ func (d *DNSServer) preparedQueryLookup(network, datacenter, query string, req,
QueryIDOrName: query,
QueryOptions: structs.QueryOptions{
Token: d.agent.config.ACLToken,
AllowStale: d.config.AllowStale,
AllowStale: *d.config.AllowStale,
},

// Always pass the local agent through. In the DNS interface, there
Expand Down
8 changes: 4 additions & 4 deletions command/agent/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,7 @@ func TestDNS_NodeLookup_TTL(t *testing.T) {
c.DNSRecursor = recursor.Addr
}, func(c *DNSConfig) {
c.NodeTTL = 10 * time.Second
c.AllowStale = true
*c.AllowStale = true
c.MaxStale = time.Second
})
defer os.RemoveAll(dir)
Expand Down Expand Up @@ -2428,7 +2428,7 @@ func TestDNS_ServiceLookup_TTL(t *testing.T) {
"db": 10 * time.Second,
"*": 5 * time.Second,
}
c.AllowStale = true
*c.AllowStale = true
c.MaxStale = time.Second
}
dir, srv := makeDNSServerConfig(t, nil, confFn)
Expand Down Expand Up @@ -2531,7 +2531,7 @@ func TestDNS_PreparedQuery_TTL(t *testing.T) {
"db": 10 * time.Second,
"*": 5 * time.Second,
}
c.AllowStale = true
*c.AllowStale = true
c.MaxStale = time.Second
}
dir, srv := makeDNSServerConfig(t, nil, confFn)
Expand Down Expand Up @@ -3192,7 +3192,7 @@ func TestDNS_NonExistingLookupEmptyAorAAAA(t *testing.T) {

func TestDNS_PreparedQuery_AllowStale(t *testing.T) {
confFn := func(c *DNSConfig) {
c.AllowStale = true
*c.AllowStale = true
c.MaxStale = time.Second
}
dir, srv := makeDNSServerConfig(t, nil, confFn)
Expand Down
5 changes: 3 additions & 2 deletions website/source/docs/agent/options.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,9 @@ Consul will not enable TLS for the HTTP API unless the `https` port has been ass
* <a name="allow_stale"></a><a href="#allow_stale">`allow_stale`</a> - Enables a stale query
for DNS information. This allows any Consul server, rather than only the leader, to service
the request. The advantage of this is you get linear read scalability with Consul servers.
By default, this is false, meaning all requests are serviced by the leader, providing stronger
consistency but less throughput and higher latency.
In versions of Consul prior to 0.7, this defaulted to false, meaning all requests are serviced
by the leader, providing stronger consistency but less throughput and higher latency. In Consul
0.7 and later, this defaults to true for better utilization of available servers.

* <a name="max_stale"></a><a href="#max_stale">`max_stale`</a> When [`allow_stale`](#allow_stale)
is specified, this is used to limit how
Expand Down
19 changes: 16 additions & 3 deletions website/source/docs/upgrade-specific.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@ standard upgrade flow.
Consul version 0.7 is a very large release with many important changes. Changes
to be aware of during an upgrade are categorized below.

#### Performance Tuning and New Defaults
#### Defaults Changed for Better Performance

Consul 0.7 introduced support for tuning Raft performance using a new
Consul 0.7 now defaults the DNS configuration to allow for stale queries by defaulting
[`allow_stale`](/docs/agent/options.html#allow_stale) to true for better utilization
of available servers. If you want to retain the previous behavior, set the following
configuration:

```javascript
{
"dns_config": {
"allow_stale": false
}
}
```

Consul also 0.7 introduced support for tuning Raft performance using a new
[performance configuration block](/docs/agent/options.html#performance). Also,
the default Raft timing is set to a lower-performance mode suitable for
[minimal Consul servers](/docs/guides/performance.html#minumum).
Expand All @@ -40,7 +53,7 @@ to all Consul servers when upgrading:

See the [Server Performance](/docs/guides/performance.html) guide for more details.

#### Default Configuration Changes
#### Servers No Longer Default to Leave on Interrupt

The default behavior of [`skip_leave_on_interrupt`](/docs/agent/options.html#skip_leave_on_interrupt)
is now dependent on whether or not the agent is acting as a server or client. When Consul is started as a
Expand Down

0 comments on commit ed7356d

Please sign in to comment.