diff --git a/api/allocations.go b/api/allocations.go index 1da3a856f34..18d1d4d6ee8 100644 --- a/api/allocations.go +++ b/api/allocations.go @@ -59,12 +59,12 @@ func (a *Allocations) Stats(alloc *Allocation, q *QueryOptions) (map[string]*Tas return nil, err } resp := make(map[string][]*TaskResourceUsage) - client.query("/v1/client/allocation/"+alloc.ID+"/stats", &resp, nil) + _, err = client.query("/v1/client/allocation/"+alloc.ID+"/stats", &resp, nil) res := make(map[string]*TaskResourceUsage) for task, ru := range resp { res[task] = ru[0] } - return res, nil + return res, err } // Allocation is used for serialization of allocations. diff --git a/command/alloc_status.go b/command/alloc_status.go index 81c1548213d..fe5943eb2d9 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -130,10 +130,9 @@ func (c *AllocStatusCommand) Run(args []string) int { return 1 } - stats, err := client.Allocations().Stats(alloc, nil) - if err != nil { - c.Ui.Error(fmt.Sprintf("couldn't retreive stats: %v", err)) - } + var statsErr error + var stats map[string]*api.TaskResourceUsage + stats, statsErr = client.Allocations().Stats(alloc, nil) // Format the allocation data basic := []string{ @@ -172,6 +171,11 @@ func (c *AllocStatusCommand) Run(args []string) int { dumpAllocStatus(c.Ui, alloc, length) } + if statsErr != nil { + c.Ui.Output("") + c.Ui.Error(fmt.Sprintf("couldn't retreive stats: %v", statsErr)) + } + return 0 }