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 attempted to address this however it only worked if the name
was left as "default".
(Completely) Fixes
@@ -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 == "" {
