Skip to content

Commit

Permalink
Merge pull request #946 from hashicorp/f-reduce-alloc-status-verbosity
Browse files Browse the repository at this point in the history
Reduce verbosity of alloc-status
  • Loading branch information
dadgar committed Mar 21, 2016
2 parents db16391 + 63e1727 commit 7e6e5c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion client/driver/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (

"github.com/hashicorp/nomad/client/allocdir"
"github.com/hashicorp/nomad/client/driver/env"
cstructs "github.com/hashicorp/nomad/client/driver/structs"
"github.com/hashicorp/nomad/client/testutil"
"github.com/hashicorp/nomad/nomad/mock"
"github.com/hashicorp/nomad/nomad/structs"
tu "github.com/hashicorp/nomad/testutil"
cstructs "github.com/hashicorp/nomad/client/driver/structs"
)

var (
Expand Down
32 changes: 21 additions & 11 deletions command/alloc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,22 @@ func (c *AllocStatusCommand) Run(args []string) int {
fmt.Sprintf("Node ID|%s", limit(alloc.NodeID, length)),
fmt.Sprintf("Job ID|%s", alloc.JobID),
fmt.Sprintf("Client Status|%s", alloc.ClientStatus),
fmt.Sprintf("Evaluated Nodes|%d", alloc.Metrics.NodesEvaluated),
fmt.Sprintf("Filtered Nodes|%d", alloc.Metrics.NodesFiltered),
fmt.Sprintf("Exhausted Nodes|%d", alloc.Metrics.NodesExhausted),
fmt.Sprintf("Allocation Time|%s", alloc.Metrics.AllocationTime),
fmt.Sprintf("Failures|%d", alloc.Metrics.CoalescedFailures),
}

if verbose {
basic = append(basic,
fmt.Sprintf("Evaluated Nodes|%d", alloc.Metrics.NodesEvaluated),
fmt.Sprintf("Filtered Nodes|%d", alloc.Metrics.NodesFiltered),
fmt.Sprintf("Exhausted Nodes|%d", alloc.Metrics.NodesExhausted),
fmt.Sprintf("Allocation Time|%s", alloc.Metrics.AllocationTime),
fmt.Sprintf("Failures|%d", alloc.Metrics.CoalescedFailures))
}
c.Ui.Output(formatKV(basic))

if !short {
c.taskResources(alloc)
}

// Print the state of each task.
if short {
c.shortTaskStatus(alloc)
Expand All @@ -142,12 +150,9 @@ func (c *AllocStatusCommand) Run(args []string) int {
}

// Format the detailed status
c.Ui.Output("\n==> Status")
dumpAllocStatus(c.Ui, alloc, length)

if !short {
c.Ui.Output("\n==> Task Resources")
c.taskResources(alloc)
if verbose || alloc.DesiredStatus == "failed" {
c.Ui.Output("\n==> Status")
dumpAllocStatus(c.Ui, alloc, length)
}

return 0
Expand Down Expand Up @@ -283,6 +288,11 @@ func (c *AllocStatusCommand) allocResources(alloc *api.Allocation) {

// taskResources prints out the tasks current resource usage
func (c *AllocStatusCommand) taskResources(alloc *api.Allocation) {
if len(alloc.TaskResources) == 0 {
return
}

c.Ui.Output("\n==> Task Resources")
firstLine := true
for task, resource := range alloc.TaskResources {
header := fmt.Sprintf("\nTask: %q", task)
Expand Down

0 comments on commit 7e6e5c0

Please sign in to comment.