Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce verbosity of alloc-status #946

Merged
merged 1 commit into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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