mirror of https://github.com/status-im/consul.git
Also make snapshot interval configurable
This commit is contained in:
parent
ad09865562
commit
d721da7b67
|
@ -766,6 +766,9 @@ func (a *Agent) consulConfig() (*consul.Config, error) {
|
||||||
if a.config.RaftSnapshotThreshold != 0 {
|
if a.config.RaftSnapshotThreshold != 0 {
|
||||||
base.RaftConfig.SnapshotThreshold = uint64(a.config.RaftSnapshotThreshold)
|
base.RaftConfig.SnapshotThreshold = uint64(a.config.RaftSnapshotThreshold)
|
||||||
}
|
}
|
||||||
|
if a.config.RaftSnapshotInterval != 0 {
|
||||||
|
base.RaftConfig.SnapshotInterval = a.config.RaftSnapshotInterval
|
||||||
|
}
|
||||||
if a.config.ACLMasterToken != "" {
|
if a.config.ACLMasterToken != "" {
|
||||||
base.ACLMasterToken = a.config.ACLMasterToken
|
base.ACLMasterToken = a.config.ACLMasterToken
|
||||||
}
|
}
|
||||||
|
|
|
@ -674,6 +674,7 @@ func (b *Builder) Build() (rt RuntimeConfig, err error) {
|
||||||
RPCRateLimit: rate.Limit(b.float64Val(c.Limits.RPCRate)),
|
RPCRateLimit: rate.Limit(b.float64Val(c.Limits.RPCRate)),
|
||||||
RaftProtocol: b.intVal(c.RaftProtocol),
|
RaftProtocol: b.intVal(c.RaftProtocol),
|
||||||
RaftSnapshotThreshold: b.intVal(c.RaftSnapshotThreshold),
|
RaftSnapshotThreshold: b.intVal(c.RaftSnapshotThreshold),
|
||||||
|
RaftSnapshotInterval: b.durationVal("raft_snapshot_interval", c.RaftSnapshotInterval),
|
||||||
ReconnectTimeoutLAN: b.durationVal("reconnect_timeout", c.ReconnectTimeoutLAN),
|
ReconnectTimeoutLAN: b.durationVal("reconnect_timeout", c.ReconnectTimeoutLAN),
|
||||||
ReconnectTimeoutWAN: b.durationVal("reconnect_timeout_wan", c.ReconnectTimeoutWAN),
|
ReconnectTimeoutWAN: b.durationVal("reconnect_timeout_wan", c.ReconnectTimeoutWAN),
|
||||||
RejoinAfterLeave: b.boolVal(c.RejoinAfterLeave),
|
RejoinAfterLeave: b.boolVal(c.RejoinAfterLeave),
|
||||||
|
|
|
@ -195,6 +195,7 @@ type Config struct {
|
||||||
RPCProtocol *int `json:"protocol,omitempty" hcl:"protocol" mapstructure:"protocol"`
|
RPCProtocol *int `json:"protocol,omitempty" hcl:"protocol" mapstructure:"protocol"`
|
||||||
RaftProtocol *int `json:"raft_protocol,omitempty" hcl:"raft_protocol" mapstructure:"raft_protocol"`
|
RaftProtocol *int `json:"raft_protocol,omitempty" hcl:"raft_protocol" mapstructure:"raft_protocol"`
|
||||||
RaftSnapshotThreshold *int `json:"raft_snapshot_threshold,omitempty" hcl:"raft_snapshot_threshold" mapstructure:"raft_snapshot_threshold"`
|
RaftSnapshotThreshold *int `json:"raft_snapshot_threshold,omitempty" hcl:"raft_snapshot_threshold" mapstructure:"raft_snapshot_threshold"`
|
||||||
|
RaftSnapshotInterval *string `json:"raft_snapshot_interval,omitempty" hcl:"raft_snapshot_interval" mapstructure:"raft_snapshot_interval"`
|
||||||
ReconnectTimeoutLAN *string `json:"reconnect_timeout,omitempty" hcl:"reconnect_timeout" mapstructure:"reconnect_timeout"`
|
ReconnectTimeoutLAN *string `json:"reconnect_timeout,omitempty" hcl:"reconnect_timeout" mapstructure:"reconnect_timeout"`
|
||||||
ReconnectTimeoutWAN *string `json:"reconnect_timeout_wan,omitempty" hcl:"reconnect_timeout_wan" mapstructure:"reconnect_timeout_wan"`
|
ReconnectTimeoutWAN *string `json:"reconnect_timeout_wan,omitempty" hcl:"reconnect_timeout_wan" mapstructure:"reconnect_timeout_wan"`
|
||||||
RejoinAfterLeave *bool `json:"rejoin_after_leave,omitempty" hcl:"rejoin_after_leave" mapstructure:"rejoin_after_leave"`
|
RejoinAfterLeave *bool `json:"rejoin_after_leave,omitempty" hcl:"rejoin_after_leave" mapstructure:"rejoin_after_leave"`
|
||||||
|
|
|
@ -905,6 +905,11 @@ type RuntimeConfig struct {
|
||||||
// hcl: raft_snapshot_threshold = int
|
// hcl: raft_snapshot_threshold = int
|
||||||
RaftSnapshotThreshold int
|
RaftSnapshotThreshold int
|
||||||
|
|
||||||
|
// RaftSnapshotInterval sets the interval to use when checking whether to create
|
||||||
|
// a new snapshot. Defaults to 5 seconds.
|
||||||
|
// hcl: raft_snapshot_threshold = int
|
||||||
|
RaftSnapshotInterval time.Duration
|
||||||
|
|
||||||
// ReconnectTimeoutLAN specifies the amount of time to wait to reconnect with
|
// ReconnectTimeoutLAN specifies the amount of time to wait to reconnect with
|
||||||
// another agent before deciding it's permanently gone. This can be used to
|
// another agent before deciding it's permanently gone. This can be used to
|
||||||
// control the time it takes to reap failed nodes from the cluster.
|
// control the time it takes to reap failed nodes from the cluster.
|
||||||
|
|
|
@ -2422,6 +2422,7 @@ func TestFullConfig(t *testing.T) {
|
||||||
"protocol": 30793,
|
"protocol": 30793,
|
||||||
"raft_protocol": 19016,
|
"raft_protocol": 19016,
|
||||||
"raft_snapshot_threshold": 16384,
|
"raft_snapshot_threshold": 16384,
|
||||||
|
"raft_snapshot_interval": "30s",
|
||||||
"reconnect_timeout": "23739s",
|
"reconnect_timeout": "23739s",
|
||||||
"reconnect_timeout_wan": "26694s",
|
"reconnect_timeout_wan": "26694s",
|
||||||
"recursors": [ "63.38.39.58", "92.49.18.18" ],
|
"recursors": [ "63.38.39.58", "92.49.18.18" ],
|
||||||
|
@ -2854,6 +2855,7 @@ func TestFullConfig(t *testing.T) {
|
||||||
protocol = 30793
|
protocol = 30793
|
||||||
raft_protocol = 19016
|
raft_protocol = 19016
|
||||||
raft_snapshot_threshold = 16384
|
raft_snapshot_threshold = 16384
|
||||||
|
raft_snapshot_interval = "30s"
|
||||||
reconnect_timeout = "23739s"
|
reconnect_timeout = "23739s"
|
||||||
reconnect_timeout_wan = "26694s"
|
reconnect_timeout_wan = "26694s"
|
||||||
recursors = [ "63.38.39.58", "92.49.18.18" ]
|
recursors = [ "63.38.39.58", "92.49.18.18" ]
|
||||||
|
@ -3412,6 +3414,7 @@ func TestFullConfig(t *testing.T) {
|
||||||
RPCMaxBurst: 44848,
|
RPCMaxBurst: 44848,
|
||||||
RaftProtocol: 19016,
|
RaftProtocol: 19016,
|
||||||
RaftSnapshotThreshold: 16384,
|
RaftSnapshotThreshold: 16384,
|
||||||
|
RaftSnapshotInterval: 30 * time.Second,
|
||||||
ReconnectTimeoutLAN: 23739 * time.Second,
|
ReconnectTimeoutLAN: 23739 * time.Second,
|
||||||
ReconnectTimeoutWAN: 26694 * time.Second,
|
ReconnectTimeoutWAN: 26694 * time.Second,
|
||||||
RejoinAfterLeave: true,
|
RejoinAfterLeave: true,
|
||||||
|
@ -4092,6 +4095,7 @@ func TestSanitize(t *testing.T) {
|
||||||
"RPCProtocol": 0,
|
"RPCProtocol": 0,
|
||||||
"RPCRateLimit": 0,
|
"RPCRateLimit": 0,
|
||||||
"RaftProtocol": 0,
|
"RaftProtocol": 0,
|
||||||
|
"RaftSnapshotInterval": "0s",
|
||||||
"RaftSnapshotThreshold": 0,
|
"RaftSnapshotThreshold": 0,
|
||||||
"ReconnectTimeoutLAN": "0s",
|
"ReconnectTimeoutLAN": "0s",
|
||||||
"ReconnectTimeoutWAN": "0s",
|
"ReconnectTimeoutWAN": "0s",
|
||||||
|
|
|
@ -448,7 +448,7 @@ func DefaultConfig() *Config {
|
||||||
// Disable shutdown on removal
|
// Disable shutdown on removal
|
||||||
conf.RaftConfig.ShutdownOnRemove = false
|
conf.RaftConfig.ShutdownOnRemove = false
|
||||||
|
|
||||||
// Check every 5 seconds to see if there are enough new entries for a snapshot
|
// Check every 5 seconds to see if there are enough new entries for a snapshot, can be overridden
|
||||||
conf.RaftConfig.SnapshotInterval = 5 * time.Second
|
conf.RaftConfig.SnapshotInterval = 5 * time.Second
|
||||||
|
|
||||||
// Snapshots are created every 8192 entries by default, can be overridden
|
// Snapshots are created every 8192 entries by default, can be overridden
|
||||||
|
|
|
@ -360,7 +360,10 @@ will exit with an error at startup.
|
||||||
for more details.
|
for more details.
|
||||||
|
|
||||||
* <a name="_raft_snapshot_threshold"></a><a href="#_raft_snapshot_threshold">`-raft-snapshot-threshold`</a> - This
|
* <a name="_raft_snapshot_threshold"></a><a href="#_raft_snapshot_threshold">`-raft-snapshot-threshold`</a> - This
|
||||||
control the minimum number of raft commit entries between snapshots that are saved to disk.
|
controls the minimum number of raft commit entries between snapshots that are saved to disk.
|
||||||
|
|
||||||
|
* <a name="_raft_snapshot_interval"></a><a href="#_raft_snapshot_interval">`-raft-snapshot-interval`</a> - This
|
||||||
|
controls how often servers check if they need to save a snapshot to disk.
|
||||||
|
|
||||||
* <a name="_recursor"></a><a href="#_recursor">`-recursor`</a> - Specifies the address of an upstream DNS
|
* <a name="_recursor"></a><a href="#_recursor">`-recursor`</a> - Specifies the address of an upstream DNS
|
||||||
server. This option may be provided multiple times, and is functionally
|
server. This option may be provided multiple times, and is functionally
|
||||||
|
@ -941,6 +944,9 @@ Consul will not enable TLS for the HTTP API unless the `https` port has been ass
|
||||||
* <a name="raft_snapshot_threshold"></a><a href="#raft_snapshot_threshold">`raft_snapshot_threshold`</a> Equivalent to the
|
* <a name="raft_snapshot_threshold"></a><a href="#raft_snapshot_threshold">`raft_snapshot_threshold`</a> Equivalent to the
|
||||||
[`-raft-snapshot-threshold` command-line flag](#_raft_snapshot_threshold).
|
[`-raft-snapshot-threshold` command-line flag](#_raft_snapshot_threshold).
|
||||||
|
|
||||||
|
* <a name="raft_snapshot_interval"></a><a href="#raft_snapshot_interval">`raft_snapshot_interval`</a> Equivalent to the
|
||||||
|
[`-raft-snapshot-interval` command-line flag](#_raft_snapshot_interval).
|
||||||
|
|
||||||
* <a name="reap"></a><a href="#reap">`reap`</a> This controls Consul's automatic reaping of child processes,
|
* <a name="reap"></a><a href="#reap">`reap`</a> This controls Consul's automatic reaping of child processes,
|
||||||
which is useful if Consul is running as PID 1 in a Docker container. If this isn't specified, then Consul will
|
which is useful if Consul is running as PID 1 in a Docker container. If this isn't specified, then Consul will
|
||||||
automatically reap child processes if it detects it is running as PID 1. If this is set to true or false, then
|
automatically reap child processes if it detects it is running as PID 1. If this is set to true or false, then
|
||||||
|
|
Loading…
Reference in New Issue