From 2892f91d0bfb95d2e52e6fda8f6859ab527aef9d Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 13 Dec 2017 10:31:45 -0800 Subject: [PATCH 1/2] Copies the autopilot settings from the runtime config. Fixes #3730 --- agent/agent.go | 31 ++++++++++--------------------- agent/config/default.go | 6 ++++++ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 2ebdd1b761..de53710272 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -767,30 +767,19 @@ func (a *Agent) consulConfig() (*consul.Config, error) { if a.config.SessionTTLMin != 0 { base.SessionTTLMin = a.config.SessionTTLMin } - if a.config.AutopilotCleanupDeadServers { - base.AutopilotConfig.CleanupDeadServers = a.config.AutopilotCleanupDeadServers - } - if a.config.AutopilotLastContactThreshold != 0 { - base.AutopilotConfig.LastContactThreshold = a.config.AutopilotLastContactThreshold - } - if a.config.AutopilotMaxTrailingLogs != 0 { - base.AutopilotConfig.MaxTrailingLogs = uint64(a.config.AutopilotMaxTrailingLogs) - } - if a.config.AutopilotServerStabilizationTime != 0 { - base.AutopilotConfig.ServerStabilizationTime = a.config.AutopilotServerStabilizationTime - } if a.config.NonVotingServer { base.NonVoter = a.config.NonVotingServer } - if a.config.AutopilotRedundancyZoneTag != "" { - base.AutopilotConfig.RedundancyZoneTag = a.config.AutopilotRedundancyZoneTag - } - if a.config.AutopilotDisableUpgradeMigration { - base.AutopilotConfig.DisableUpgradeMigration = a.config.AutopilotDisableUpgradeMigration - } - if a.config.AutopilotUpgradeVersionTag != "" { - base.AutopilotConfig.UpgradeVersionTag = a.config.AutopilotUpgradeVersionTag - } + + // These are fully specified in the agent defaults, so we can simply + // copy them over. + base.AutopilotConfig.CleanupDeadServers = a.config.AutopilotCleanupDeadServers + base.AutopilotConfig.LastContactThreshold = a.config.AutopilotLastContactThreshold + base.AutopilotConfig.MaxTrailingLogs = uint64(a.config.AutopilotMaxTrailingLogs) + base.AutopilotConfig.ServerStabilizationTime = a.config.AutopilotServerStabilizationTime + base.AutopilotConfig.RedundancyZoneTag = a.config.AutopilotRedundancyZoneTag + base.AutopilotConfig.DisableUpgradeMigration = a.config.AutopilotDisableUpgradeMigration + base.AutopilotConfig.UpgradeVersionTag = a.config.AutopilotUpgradeVersionTag // make sure the advertise address is always set if base.RPCAdvertise == nil { diff --git a/agent/config/default.go b/agent/config/default.go index 6bc3295c42..1c52c7ac36 100644 --- a/agent/config/default.go +++ b/agent/config/default.go @@ -54,6 +54,12 @@ func DefaultSource() Source { syslog_facility = "LOCAL0" tls_min_version = "tls10" + autopilot = { + cleanup_dead_servers = true + last_contact_threshold = "200ms" + max_trailing_logs = 250 + server_stabilization_time = "10s" + } dns_config = { allow_stale = true udp_answer_limit = 3 From 46742a5041883c914b20d52556ee5df4efb94542 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 13 Dec 2017 10:52:06 -0800 Subject: [PATCH 2/2] Adds TODOs referencing #3744. --- agent/config/default.go | 2 ++ agent/consul/config.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/agent/config/default.go b/agent/config/default.go index 1c52c7ac36..f3a0adfc5a 100644 --- a/agent/config/default.go +++ b/agent/config/default.go @@ -54,6 +54,8 @@ func DefaultSource() Source { syslog_facility = "LOCAL0" tls_min_version = "tls10" + // TODO (slackpad) - Until #3744 is done, we need to keep these + // in sync with agent/consul/config.go. autopilot = { cleanup_dead_servers = true last_contact_threshold = "200ms" diff --git a/agent/consul/config.go b/agent/consul/config.go index ffbd35ef9b..5bc89ebaa7 100644 --- a/agent/consul/config.go +++ b/agent/consul/config.go @@ -416,12 +416,15 @@ func DefaultConfig() *Config { TLSMinVersion: "tls10", + // TODO (slackpad) - Until #3744 is done, we need to keep these + // in sync with agent/config/default.go. AutopilotConfig: &structs.AutopilotConfig{ CleanupDeadServers: true, LastContactThreshold: 200 * time.Millisecond, MaxTrailingLogs: 250, ServerStabilizationTime: 10 * time.Second, }, + ServerHealthInterval: 2 * time.Second, AutopilotInterval: 10 * time.Second, }