From 7f7c0ad65e9a4061a575d5a38bd54acf341e109e Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Fri, 30 Jun 2017 11:09:52 +0200 Subject: [PATCH] agent: clone partial consul config The agent configuration for the consul server is a partial configuration which needs to be cloned to avoid data races. This is a stop-gap measure before moving the configuration into a separate package. --- agent/agent.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/agent/agent.go b/agent/agent.go index 92055bb125..54f96082e0 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -551,8 +551,13 @@ func (a *Agent) reloadWatches(cfg *Config) error { func (a *Agent) consulConfig() (*consul.Config, error) { // Start with the provided config or default config base := consul.DefaultConfig() + + // a.config.ConsulConfig, if set, is a partial configuration for the + // consul server or client. Therefore, clone and augment it but + // don't use it as base directly. if a.config.ConsulConfig != nil { - base = a.config.ConsulConfig + base = new(consul.Config) + *base = *a.config.ConsulConfig } // This is set when the agent starts up