Handle the case where there are no healthy servers

Pointed out by: @slackpad
This commit is contained in:
Sean Chittenden 2016-02-19 13:17:52 -08:00
parent 09d4c6439c
commit 82458fa9e8
1 changed files with 5 additions and 0 deletions

View File

@ -350,6 +350,11 @@ func (c *Client) RPC(method string, args interface{}, reply interface{}) error {
}
}
if server == nil {
c.logger.Printf("[ERR] consul: No healthy servers found in the server config")
return structs.ErrNoServers
}
// Forward to remote Consul
if err := c.connPool.RPC(c.config.Datacenter, server.Addr, server.Version, method, args, reply); err != nil {
atomic.AddUint64(&server.Disabled, 1)