Merge pull request #1121 from hashicorp/f-server-members

`nomad server-members`: Better error handling of no cluster leader in federated clusters
This commit is contained in:
Alex Dadgar 2016-04-22 16:08:33 -07:00
commit effb82a614
1 changed files with 7 additions and 2 deletions

View File

@ -74,7 +74,7 @@ func (c *ServerMembersCommand) Run(args []string) int {
// Determine the leaders per region.
leaders, err := regionLeaders(client, mem)
if err != nil && !strings.Contains(err.Error(), "No cluster leader") {
if err != nil {
c.Ui.Error(fmt.Sprintf("Error determining leaders: %s", err))
return 1
}
@ -160,8 +160,13 @@ func regionLeaders(client *api.Client, mem []*api.AgentMember) (map[string]strin
for reg := range regions {
l, err := status.RegionLeader(reg)
if err != nil {
return leaders, err
// This error means that region has no leader.
if strings.Contains(err.Error(), "No cluster leader") {
continue
}
return nil, err
}
leaders[reg] = l
}