agent: Adding new CheckUpdateInterval config
This commit is contained in:
parent
e21b338a8b
commit
c99e6e082c
|
@ -173,6 +173,14 @@ type Config struct {
|
||||||
// true, we ignore the leave, and rejoin the cluster on start.
|
// true, we ignore the leave, and rejoin the cluster on start.
|
||||||
RejoinAfterLeave bool `mapstructure:"rejoin_after_leave"`
|
RejoinAfterLeave bool `mapstructure:"rejoin_after_leave"`
|
||||||
|
|
||||||
|
// CheckUpdateInterval controls the interval on which the output of a health check
|
||||||
|
// is updated if there is no change to the state. For example, a check in a steady
|
||||||
|
// state may run every 5 second generating a unique output (timestamp, etc), forcing
|
||||||
|
// constant writes. This allows Consul to defer the write for some period of time,
|
||||||
|
// reducing the write pressure when the state is steady.
|
||||||
|
CheckUpdateInterval time.Duration `mapstructure:"-"`
|
||||||
|
CheckUpdateIntervalRaw string `mapstructure:"check_update_interval" json:"-"`
|
||||||
|
|
||||||
// AEInterval controls the anti-entropy interval. This is how often
|
// AEInterval controls the anti-entropy interval. This is how often
|
||||||
// the agent attempts to reconcile it's local state with the server'
|
// the agent attempts to reconcile it's local state with the server'
|
||||||
// representation of our state. Defaults to every 60s.
|
// representation of our state. Defaults to every 60s.
|
||||||
|
@ -220,8 +228,9 @@ func DefaultConfig() *Config {
|
||||||
DNSConfig: DNSConfig{
|
DNSConfig: DNSConfig{
|
||||||
MaxStale: 5 * time.Second,
|
MaxStale: 5 * time.Second,
|
||||||
},
|
},
|
||||||
Protocol: consul.ProtocolVersionMax,
|
Protocol: consul.ProtocolVersionMax,
|
||||||
AEInterval: time.Minute,
|
CheckUpdateInterval: 5 * time.Minute,
|
||||||
|
AEInterval: time.Minute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +318,14 @@ func DecodeConfig(r io.Reader) (*Config, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if raw := result.CheckUpdateIntervalRaw; raw != "" {
|
||||||
|
dur, err := time.ParseDuration(raw)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("CheckUpdateInterval invalid: %v", err)
|
||||||
|
}
|
||||||
|
result.CheckUpdateInterval = dur
|
||||||
|
}
|
||||||
|
|
||||||
return &result, nil
|
return &result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,6 +553,9 @@ func MergeConfig(a, b *Config) *Config {
|
||||||
if b.DNSConfig.MaxStale != 0 {
|
if b.DNSConfig.MaxStale != 0 {
|
||||||
result.DNSConfig.MaxStale = b.DNSConfig.MaxStale
|
result.DNSConfig.MaxStale = b.DNSConfig.MaxStale
|
||||||
}
|
}
|
||||||
|
if b.CheckUpdateInterval != 0 {
|
||||||
|
result.CheckUpdateInterval = b.CheckUpdateInterval
|
||||||
|
}
|
||||||
|
|
||||||
// Copy the start join addresses
|
// Copy the start join addresses
|
||||||
result.StartJoin = make([]string, 0, len(a.StartJoin)+len(b.StartJoin))
|
result.StartJoin = make([]string, 0, len(a.StartJoin)+len(b.StartJoin))
|
||||||
|
|
|
@ -324,6 +324,17 @@ func TestDecodeConfig(t *testing.T) {
|
||||||
if config.DNSConfig.ServiceTTL["web"] != 30*time.Second {
|
if config.DNSConfig.ServiceTTL["web"] != 30*time.Second {
|
||||||
t.Fatalf("bad: %#v", config)
|
t.Fatalf("bad: %#v", config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckUpdateInterval
|
||||||
|
input = `{"check_update_interval": "10m"}`
|
||||||
|
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.CheckUpdateInterval != 10*time.Minute {
|
||||||
|
t.Fatalf("bad: %#v", config)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDecodeConfig_Service(t *testing.T) {
|
func TestDecodeConfig_Service(t *testing.T) {
|
||||||
|
@ -451,21 +462,22 @@ func TestMergeConfig(t *testing.T) {
|
||||||
SerfWan: 5,
|
SerfWan: 5,
|
||||||
Server: 6,
|
Server: 6,
|
||||||
},
|
},
|
||||||
Server: true,
|
Server: true,
|
||||||
LeaveOnTerm: true,
|
LeaveOnTerm: true,
|
||||||
SkipLeaveOnInt: true,
|
SkipLeaveOnInt: true,
|
||||||
EnableDebug: true,
|
EnableDebug: true,
|
||||||
VerifyIncoming: true,
|
VerifyIncoming: true,
|
||||||
VerifyOutgoing: true,
|
VerifyOutgoing: true,
|
||||||
CAFile: "test/ca.pem",
|
CAFile: "test/ca.pem",
|
||||||
CertFile: "test/cert.pem",
|
CertFile: "test/cert.pem",
|
||||||
KeyFile: "test/key.pem",
|
KeyFile: "test/key.pem",
|
||||||
Checks: []*CheckDefinition{nil},
|
Checks: []*CheckDefinition{nil},
|
||||||
Services: []*ServiceDefinition{nil},
|
Services: []*ServiceDefinition{nil},
|
||||||
StartJoin: []string{"1.1.1.1"},
|
StartJoin: []string{"1.1.1.1"},
|
||||||
UiDir: "/opt/consul-ui",
|
UiDir: "/opt/consul-ui",
|
||||||
EnableSyslog: true,
|
EnableSyslog: true,
|
||||||
RejoinAfterLeave: true,
|
RejoinAfterLeave: true,
|
||||||
|
CheckUpdateInterval: 8 * time.Minute,
|
||||||
}
|
}
|
||||||
|
|
||||||
c := MergeConfig(a, b)
|
c := MergeConfig(a, b)
|
||||||
|
|
Loading…
Reference in New Issue