mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 11:25:41 +03:00
add Created At to nomad alloc-status
This commit is contained in:
@@ -220,6 +220,7 @@ 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("Created At|%s", formatUnixNanoTime(alloc.CreateTime)),
|
||||
}
|
||||
|
||||
if verbose {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/testutil"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
@@ -71,3 +72,53 @@ func TestAllocStatusCommand_Fails(t *testing.T) {
|
||||
t.Fatalf("expected getting formatter error, got: %s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAllocStatusCommand_Run(t *testing.T) {
|
||||
srv, client, url := testServer(t, func(c *testutil.TestServerConfig) {
|
||||
c.DevMode = true
|
||||
})
|
||||
defer srv.Stop()
|
||||
ui := new(cli.MockUi)
|
||||
cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}}
|
||||
|
||||
jobID := "job1_sfx"
|
||||
job1 := testJob(jobID)
|
||||
evalId1, _, err := client.Jobs().Register(job1, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
if code := waitForSuccess(ui, client, fullId, t, evalId1); code != 0 {
|
||||
t.Fatalf("status code non zero saw %d", code)
|
||||
}
|
||||
// get an alloc id
|
||||
allocId1 := ""
|
||||
if allocs, _, err := client.Jobs().Allocations(jobID, nil); err == nil {
|
||||
if len(allocs) > 0 {
|
||||
allocId1 = allocs[0].ID
|
||||
}
|
||||
}
|
||||
if allocId1 == "" {
|
||||
t.Fatal("unable to find an allocation")
|
||||
}
|
||||
|
||||
if code := cmd.Run([]string{"-address=" + url, allocId1}); code != 0 {
|
||||
t.Fatalf("expected exit 0, got: %d", code)
|
||||
}
|
||||
out := ui.OutputWriter.String()
|
||||
if !strings.Contains(out, "Created At") {
|
||||
t.Fatalf("expected to have 'Created At' but saw: %s", out)
|
||||
}
|
||||
ui.OutputWriter.Reset()
|
||||
|
||||
if code := cmd.Run([]string{"-address=" + url, "-verbose", allocId1}); code != 0 {
|
||||
t.Fatalf("expected exit 0, got: %d", code)
|
||||
}
|
||||
out = ui.OutputWriter.String()
|
||||
if !strings.Contains(out, allocId1) {
|
||||
t.Fatal("expected to find alloc id in output");
|
||||
}
|
||||
if !strings.Contains(out, "Created At") {
|
||||
t.Fatalf("expected to have 'Created At' but saw: %s", out)
|
||||
}
|
||||
ui.OutputWriter.Reset()
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ Name = example.cache[0]
|
||||
Node ID = 1f029d38
|
||||
Job ID = example
|
||||
Client Status = running
|
||||
Created At = 29/03/16 03:04:53 UTC
|
||||
|
||||
==> Tasks
|
||||
Name State Last Event Time
|
||||
@@ -63,6 +64,7 @@ Name = example.cache[0]
|
||||
Node ID = 1f029d38
|
||||
Job ID = example
|
||||
Client Status = running
|
||||
Created At = 29/03/16 03:04:53 UTC
|
||||
|
||||
==> Task Resources
|
||||
Task: "redis"
|
||||
@@ -91,13 +93,14 @@ Time Type Description
|
||||
Verbose status can also be accessed:
|
||||
|
||||
```
|
||||
$ nomad alloc-status a7365fe4
|
||||
$ nomad alloc-status --verbose a7365fe4
|
||||
ID = a7365fe4-cb28-a6e9-f3d4-f99e49c89776
|
||||
Eval ID = c3c9a1db-dbeb-8afa-0a83-4f1b8b5a03f5
|
||||
Name = example.cache[0]
|
||||
Node ID = 1f029d38-8d4b-a552-261f-e457b60f9b4b
|
||||
Job ID = example
|
||||
Client Status = running
|
||||
Created At = 29/03/16 03:04:53 UTC
|
||||
Evaluated Nodes = 1
|
||||
Filtered Nodes = 0
|
||||
Exhausted Nodes = 0
|
||||
|
||||
@@ -90,6 +90,7 @@ Name = example.cache[1]
|
||||
Node ID = 4beef22f
|
||||
Job ID = example
|
||||
Client Status = running
|
||||
Created At = 06/28/16 15:37:44 UTC
|
||||
|
||||
Task "redis" is "running"
|
||||
Task Resources
|
||||
@@ -126,6 +127,7 @@ Name = example.cache[0]
|
||||
Node ID = 13063955
|
||||
Job ID = example
|
||||
Client Status = failed
|
||||
Created At = 06/28/16 15:50:22 UTC
|
||||
|
||||
Task "redis" is "dead"
|
||||
Task Resources
|
||||
@@ -153,6 +155,7 @@ Name = example.cache[0]
|
||||
Node ID = 83ef596c
|
||||
Job ID = example
|
||||
Client Status = pending
|
||||
Created At = 06/28/16 15:55:48
|
||||
|
||||
Task "redis" is "pending"
|
||||
Task Resources
|
||||
|
||||
@@ -24,6 +24,7 @@ Name = example.cache[0]
|
||||
Node ID = 39acd6e0
|
||||
Job ID = example
|
||||
Client Status = running
|
||||
Created At = 06/28/16 16:42:42 UTC
|
||||
|
||||
Task "redis" is "running"
|
||||
Task Resources
|
||||
|
||||
@@ -93,6 +93,7 @@ Name = example.cache[0]
|
||||
Node ID = 72687b1a
|
||||
Job ID = example
|
||||
Client Status = running
|
||||
Created At = 06/23/16 01:41:13 UTC
|
||||
|
||||
Task "redis" is "running"
|
||||
Task Resources
|
||||
|
||||
Reference in New Issue
Block a user