mirror of https://github.com/docker/docs.git
Add error message when discovery service returns non 200
status code. Update doc for token.go/Fetch Signed-off-by: Ankush Agarwal <ankushagarwal11@gmail.com>
This commit is contained in:
parent
9d5fe6949e
commit
b3bcab711e
|
|
@ -36,8 +36,9 @@ func (s *TokenDiscoveryService) Initialize(urltoken string, heartbeat int) error
|
|||
return nil
|
||||
}
|
||||
|
||||
// FetchNodes returns the node for the discovery service at the specified endpoint
|
||||
// Fetch returns the list of nodes for the discovery service at the specified endpoint
|
||||
func (s *TokenDiscoveryService) Fetch() ([]*discovery.Node, error) {
|
||||
|
||||
resp, err := http.Get(fmt.Sprintf("%s/%s/%s", s.url, "clusters", s.token))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -52,6 +53,10 @@ func (s *TokenDiscoveryService) Fetch() ([]*discovery.Node, error) {
|
|||
if err := json.NewDecoder(resp.Body).Decode(&addrs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("Failed to fetch nodes from Discovery service. "+
|
||||
"Discovery service returned %d HTTP status code", resp.StatusCode)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var nodes []*discovery.Node
|
||||
|
|
|
|||
Loading…
Reference in New Issue