Skip to content

Commit

Permalink
etcdserver: add error details on DNS resolution failure on advertise …
Browse files Browse the repository at this point in the history
…URLs

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Jan 25, 2018
1 parent 7dd9c30 commit 2b10bcc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions etcdserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ func (c *ServerConfig) advertiseMatchesCluster() error {
sort.Strings(apurls)
ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
defer cancel()
if netutil.URLStringsEqual(ctx, apurls, urls.StringSlice()) {
ok, err := netutil.URLStringsEqual(ctx, apurls, urls.StringSlice())
if ok {
return nil
}

Expand All @@ -148,17 +149,24 @@ func (c *ServerConfig) advertiseMatchesCluster() error {
}
mstr := strings.Join(missing, ",")
apStr := strings.Join(apurls, ",")
return fmt.Errorf("--initial-cluster has %s but missing from --initial-advertise-peer-urls=%s ", mstr, apStr)
return fmt.Errorf("--initial-cluster has %s but missing from --initial-advertise-peer-urls=%s (%v)", mstr, apStr, err)
}

for url := range apMap {
if _, ok := initMap[url]; !ok {
missing = append(missing, url)
}
}
mstr := strings.Join(missing, ",")
if len(missing) > 0 {
mstr := strings.Join(missing, ",")
umap := types.URLsMap(map[string]types.URLs{c.Name: c.PeerURLs})
return fmt.Errorf("--initial-advertise-peer-urls has %s but missing from --initial-cluster=%s", mstr, umap.String())
}

// resolved URLs from "--initial-advertise-peer-urls" and "--initial-cluster" did not match or failed
apStr := strings.Join(apurls, ",")
umap := types.URLsMap(map[string]types.URLs{c.Name: c.PeerURLs})
return fmt.Errorf("--initial-advertise-peer-urls has %s but missing from --initial-cluster=%s", mstr, umap.String())
return fmt.Errorf("failed to resolve %s to match --initial-cluster=%s (%v)", apStr, umap.String(), err)
}

func (c *ServerConfig) MemberDir() string { return filepath.Join(c.DataDir, "member") }
Expand Down

0 comments on commit 2b10bcc

Please sign in to comment.