From d0d4b1378b95d87e9115d94eb098667eb5b0a5df Mon Sep 17 00:00:00 2001 From: Jonathan Sokolowski Date: Tue, 28 Mar 2017 16:26:02 +1100 Subject: [PATCH] embed: Delay setting initial cluster for YAML NewConfig() sets an initial cluster (potentially using a default name) but we should clear it in the event another discovery option has been specified. PR #7517 attempted to address this however it only worked if the name was left as "default". (Completely) Fixes #7516 --- embed/config.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/embed/config.go b/embed/config.go index 56fd3f35c..aaf6d1be5 100644 --- a/embed/config.go +++ b/embed/config.go @@ -203,6 +203,8 @@ func (cfg *configYAML) configFromFile(path string) error { return err } + defaultInitialCluster := cfg.InitialCluster + err = yaml.Unmarshal(b, cfg) if err != nil { return err @@ -246,7 +248,8 @@ func (cfg *configYAML) configFromFile(path string) error { cfg.ACUrls = []url.URL(u) } - if (cfg.Durl != "" || cfg.DNSCluster != "") && cfg.InitialCluster == cfg.InitialClusterFromName(cfg.Name) { + // If a discovery flag is set, clear default initial cluster set by InitialClusterFromName + if (cfg.Durl != "" || cfg.DNSCluster != "") && cfg.InitialCluster == defaultInitialCluster { cfg.InitialCluster = "" } if cfg.ClusterState == "" {