Browse Source

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
Jonathan Sokolowski 8 years ago
parent
commit
d0d4b1378b
1 changed files with 4 additions and 1 deletions
  1. 4 1
      embed/config.go

+ 4 - 1
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 == "" {