From b1e392405caf944d9e49efb7e1aeb0743ecd2f8b Mon Sep 17 00:00:00 2001 From: Sean Chittenden Date: Fri, 19 Feb 2016 13:17:52 -0800 Subject: [PATCH] Handle the case where there are no healthy servers Pointed out by: @slackpad --- consul/client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/consul/client.go b/consul/client.go index edf8890dfc..36bfe7c0da 100644 --- a/consul/client.go +++ b/consul/client.go @@ -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)