Skip to content

Commit

Permalink
sanity check returned current member list
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-deboer committed Mar 21, 2017
1 parent a8d3461 commit f059a5b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pkg/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,23 @@ func (d *Discovery) resolveMembersAndAPI(expectedMembers []etcd.Member, localMem
lastErr = err
continue
}
if log.GetLevel() >= log.DebugLevel {
log.Debugf("Actual cluster members: %#v", currentMembers)
// sanity-check the returned members; it may be partial in case of a yet-forming cluster
hasInvalidMembers := false
for _, m := range currentMembers {
if len(m.Name) == 0 || len(m.PeerURLs) == 0 {
if log.GetLevel() >= log.DebugLevel {
log.Debugf("Returned actual member list contains invalid member: %#v", m)
}
hasInvalidMembers = true
break
}
}
if !hasInvalidMembers {
if log.GetLevel() >= log.DebugLevel {
log.Debugf("Actual cluster members: %#v", currentMembers)
}
return membersAPI, currentMembers, nil
}
return membersAPI, currentMembers, nil
}
}
if len(currentMembers) == 0 {
Expand Down

0 comments on commit f059a5b

Please sign in to comment.