mirror of https://github.com/status-im/consul.git
Merge pull request #2315 from hashicorp/f-allow-stale
Changes default DNS allow_stale to true.
This commit is contained in:
commit
f894f333f5
|
@ -68,7 +68,7 @@ type DNSConfig struct {
|
||||||
// data. This gives horizontal read scalability since
|
// data. This gives horizontal read scalability since
|
||||||
// any Consul server can service the query instead of
|
// any Consul server can service the query instead of
|
||||||
// only the leader.
|
// only the leader.
|
||||||
AllowStale bool `mapstructure:"allow_stale"`
|
AllowStale *bool `mapstructure:"allow_stale"`
|
||||||
|
|
||||||
// EnableTruncate is used to enable setting the truncate
|
// EnableTruncate is used to enable setting the truncate
|
||||||
// flag for UDP DNS queries. This allows unmodified
|
// flag for UDP DNS queries. This allows unmodified
|
||||||
|
@ -644,6 +644,7 @@ func DefaultConfig() *Config {
|
||||||
Server: 8300,
|
Server: 8300,
|
||||||
},
|
},
|
||||||
DNSConfig: DNSConfig{
|
DNSConfig: DNSConfig{
|
||||||
|
AllowStale: Bool(true),
|
||||||
UDPAnswerLimit: 3,
|
UDPAnswerLimit: 3,
|
||||||
MaxStale: 5 * time.Second,
|
MaxStale: 5 * time.Second,
|
||||||
},
|
},
|
||||||
|
@ -1335,8 +1336,8 @@ func MergeConfig(a, b *Config) *Config {
|
||||||
result.DNSConfig.ServiceTTL[service] = dur
|
result.DNSConfig.ServiceTTL[service] = dur
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if b.DNSConfig.AllowStale {
|
if b.DNSConfig.AllowStale != nil {
|
||||||
result.DNSConfig.AllowStale = true
|
result.DNSConfig.AllowStale = b.DNSConfig.AllowStale
|
||||||
}
|
}
|
||||||
if b.DNSConfig.UDPAnswerLimit != 0 {
|
if b.DNSConfig.UDPAnswerLimit != 0 {
|
||||||
result.DNSConfig.UDPAnswerLimit = b.DNSConfig.UDPAnswerLimit
|
result.DNSConfig.UDPAnswerLimit = b.DNSConfig.UDPAnswerLimit
|
||||||
|
|
|
@ -544,13 +544,13 @@ 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}}`
|
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)))
|
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !config.DNSConfig.AllowStale {
|
if *config.DNSConfig.AllowStale {
|
||||||
t.Fatalf("bad: %#v", config)
|
t.Fatalf("bad: %#v", config)
|
||||||
}
|
}
|
||||||
if config.DNSConfig.EnableTruncate {
|
if config.DNSConfig.EnableTruncate {
|
||||||
|
@ -1408,7 +1408,7 @@ func TestMergeConfig(t *testing.T) {
|
||||||
DataDir: "/tmp/bar",
|
DataDir: "/tmp/bar",
|
||||||
DNSRecursors: []string{"127.0.0.2:1001"},
|
DNSRecursors: []string{"127.0.0.2:1001"},
|
||||||
DNSConfig: DNSConfig{
|
DNSConfig: DNSConfig{
|
||||||
AllowStale: false,
|
AllowStale: Bool(false),
|
||||||
EnableTruncate: true,
|
EnableTruncate: true,
|
||||||
DisableCompression: true,
|
DisableCompression: true,
|
||||||
MaxStale: 30 * time.Second,
|
MaxStale: 30 * time.Second,
|
||||||
|
|
|
@ -198,7 +198,7 @@ func (d *DNSServer) handlePtr(resp dns.ResponseWriter, req *dns.Msg) {
|
||||||
Datacenter: datacenter,
|
Datacenter: datacenter,
|
||||||
QueryOptions: structs.QueryOptions{
|
QueryOptions: structs.QueryOptions{
|
||||||
Token: d.agent.config.ACLToken,
|
Token: d.agent.config.ACLToken,
|
||||||
AllowStale: d.config.AllowStale,
|
AllowStale: *d.config.AllowStale,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var out structs.IndexedNodes
|
var out structs.IndexedNodes
|
||||||
|
@ -384,7 +384,7 @@ func (d *DNSServer) nodeLookup(network, datacenter, node string, req, resp *dns.
|
||||||
Node: node,
|
Node: node,
|
||||||
QueryOptions: structs.QueryOptions{
|
QueryOptions: structs.QueryOptions{
|
||||||
Token: d.agent.config.ACLToken,
|
Token: d.agent.config.ACLToken,
|
||||||
AllowStale: d.config.AllowStale,
|
AllowStale: *d.config.AllowStale,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var out structs.IndexedNodeServices
|
var out structs.IndexedNodeServices
|
||||||
|
@ -584,7 +584,7 @@ func (d *DNSServer) serviceLookup(network, datacenter, service, tag string, req,
|
||||||
TagFilter: tag != "",
|
TagFilter: tag != "",
|
||||||
QueryOptions: structs.QueryOptions{
|
QueryOptions: structs.QueryOptions{
|
||||||
Token: d.agent.config.ACLToken,
|
Token: d.agent.config.ACLToken,
|
||||||
AllowStale: d.config.AllowStale,
|
AllowStale: *d.config.AllowStale,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var out structs.IndexedCheckServiceNodes
|
var out structs.IndexedCheckServiceNodes
|
||||||
|
@ -658,7 +658,7 @@ func (d *DNSServer) preparedQueryLookup(network, datacenter, query string, req,
|
||||||
QueryIDOrName: query,
|
QueryIDOrName: query,
|
||||||
QueryOptions: structs.QueryOptions{
|
QueryOptions: structs.QueryOptions{
|
||||||
Token: d.agent.config.ACLToken,
|
Token: d.agent.config.ACLToken,
|
||||||
AllowStale: d.config.AllowStale,
|
AllowStale: *d.config.AllowStale,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Always pass the local agent through. In the DNS interface, there
|
// Always pass the local agent through. In the DNS interface, there
|
||||||
|
|
|
@ -2308,7 +2308,7 @@ func TestDNS_NodeLookup_TTL(t *testing.T) {
|
||||||
c.DNSRecursor = recursor.Addr
|
c.DNSRecursor = recursor.Addr
|
||||||
}, func(c *DNSConfig) {
|
}, func(c *DNSConfig) {
|
||||||
c.NodeTTL = 10 * time.Second
|
c.NodeTTL = 10 * time.Second
|
||||||
c.AllowStale = true
|
*c.AllowStale = true
|
||||||
c.MaxStale = time.Second
|
c.MaxStale = time.Second
|
||||||
})
|
})
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
@ -2428,7 +2428,7 @@ func TestDNS_ServiceLookup_TTL(t *testing.T) {
|
||||||
"db": 10 * time.Second,
|
"db": 10 * time.Second,
|
||||||
"*": 5 * time.Second,
|
"*": 5 * time.Second,
|
||||||
}
|
}
|
||||||
c.AllowStale = true
|
*c.AllowStale = true
|
||||||
c.MaxStale = time.Second
|
c.MaxStale = time.Second
|
||||||
}
|
}
|
||||||
dir, srv := makeDNSServerConfig(t, nil, confFn)
|
dir, srv := makeDNSServerConfig(t, nil, confFn)
|
||||||
|
@ -2531,7 +2531,7 @@ func TestDNS_PreparedQuery_TTL(t *testing.T) {
|
||||||
"db": 10 * time.Second,
|
"db": 10 * time.Second,
|
||||||
"*": 5 * time.Second,
|
"*": 5 * time.Second,
|
||||||
}
|
}
|
||||||
c.AllowStale = true
|
*c.AllowStale = true
|
||||||
c.MaxStale = time.Second
|
c.MaxStale = time.Second
|
||||||
}
|
}
|
||||||
dir, srv := makeDNSServerConfig(t, nil, confFn)
|
dir, srv := makeDNSServerConfig(t, nil, confFn)
|
||||||
|
@ -3192,7 +3192,7 @@ func TestDNS_NonExistingLookupEmptyAorAAAA(t *testing.T) {
|
||||||
|
|
||||||
func TestDNS_PreparedQuery_AllowStale(t *testing.T) {
|
func TestDNS_PreparedQuery_AllowStale(t *testing.T) {
|
||||||
confFn := func(c *DNSConfig) {
|
confFn := func(c *DNSConfig) {
|
||||||
c.AllowStale = true
|
*c.AllowStale = true
|
||||||
c.MaxStale = time.Second
|
c.MaxStale = time.Second
|
||||||
}
|
}
|
||||||
dir, srv := makeDNSServerConfig(t, nil, confFn)
|
dir, srv := makeDNSServerConfig(t, nil, confFn)
|
||||||
|
|
|
@ -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
|
* <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
|
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.
|
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
|
In versions of Consul prior to 0.7, this defaulted to false, meaning all requests are serviced
|
||||||
consistency but less throughput and higher latency.
|
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)
|
* <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
|
is specified, this is used to limit how
|
||||||
|
|
|
@ -19,9 +19,22 @@ standard upgrade flow.
|
||||||
Consul version 0.7 is a very large release with many important changes. Changes
|
Consul version 0.7 is a very large release with many important changes. Changes
|
||||||
to be aware of during an upgrade are categorized below.
|
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,
|
[performance configuration block](/docs/agent/options.html#performance). Also,
|
||||||
the default Raft timing is set to a lower-performance mode suitable for
|
the default Raft timing is set to a lower-performance mode suitable for
|
||||||
[minimal Consul servers](/docs/guides/performance.html#minumum).
|
[minimal Consul servers](/docs/guides/performance.html#minumum).
|
||||||
|
@ -40,7 +53,7 @@ to all Consul servers when upgrading:
|
||||||
|
|
||||||
See the [Server Performance](/docs/guides/performance.html) guide for more details.
|
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)
|
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
|
is now dependent on whether or not the agent is acting as a server or client. When Consul is started as a
|
||||||
|
|
Loading…
Reference in New Issue