Browse Source

etcdserver: optimized veryfying local member

moved the code for perparing and sorting of advertising peer urls and
sorting of peer urls only when strict verification needs to be done.
This is done to avoid this processing when strict verification is not
required like in case of VerifyJoinExisting function.

#6165
sharat 9 years ago
parent
commit
1fec4ba127
1 changed files with 4 additions and 4 deletions
  1. 4 4
      etcdserver/config.go

+ 4 - 4
etcdserver/config.go

@@ -104,11 +104,11 @@ func (c *ServerConfig) verifyLocalMember(strict bool) error {
 		return fmt.Errorf("couldn't find local name %q in the initial cluster configuration", c.Name)
 		return fmt.Errorf("couldn't find local name %q in the initial cluster configuration", c.Name)
 	}
 	}
 
 
-	// Advertised peer URLs must match those in the cluster peer list
-	apurls := c.PeerURLs.StringSlice()
-	sort.Strings(apurls)
-	urls.Sort()
 	if strict {
 	if strict {
+		// Advertised peer URLs must match those in the cluster peer list
+		apurls := c.PeerURLs.StringSlice()
+		sort.Strings(apurls)
+		urls.Sort()
 		if !netutil.URLStringsEqual(apurls, urls.StringSlice()) {
 		if !netutil.URLStringsEqual(apurls, urls.StringSlice()) {
 			umap := map[string]types.URLs{c.Name: c.PeerURLs}
 			umap := map[string]types.URLs{c.Name: c.PeerURLs}
 			return fmt.Errorf("--initial-cluster must include %s given --initial-advertise-peer-urls=%s", types.URLsMap(umap).String(), strings.Join(apurls, ","))
 			return fmt.Errorf("--initial-cluster must include %s given --initial-advertise-peer-urls=%s", types.URLsMap(umap).String(), strings.Join(apurls, ","))