Skip to content

Commit

Permalink
Moving the stats error to the bottom of alloc status
Browse files Browse the repository at this point in the history
  • Loading branch information
diptanu committed Jun 8, 2016
1 parent 5b50e01 commit 4fc5eed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions api/allocations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 8 additions & 4 deletions command/alloc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 4fc5eed

Please sign in to comment.