mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Don't query for node-status if the node is down and handle the errors
This commit is contained in:
@@ -8,6 +8,12 @@ import (
|
||||
"github.com/hashicorp/go-cleanhttp"
|
||||
)
|
||||
|
||||
var (
|
||||
// NodeDownErr marks an operational as not able to complete since the node
|
||||
// is down.
|
||||
NodeDownErr = fmt.Errorf("node down")
|
||||
)
|
||||
|
||||
// Allocations is used to query the alloc-related endpoints.
|
||||
type Allocations struct {
|
||||
client *Client
|
||||
@@ -48,6 +54,9 @@ func (a *Allocations) Stats(alloc *Allocation, q *QueryOptions) (*AllocResourceU
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if node.Status == "down" {
|
||||
return nil, NodeDownErr
|
||||
}
|
||||
if node.HTTPAddr == "" {
|
||||
return nil, fmt.Errorf("http addr of the node where alloc %q is running is not advertised", alloc.ID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user