From bc6db9c138fb2461f77723ca2717ae8e47f45198 Mon Sep 17 00:00:00 2001 From: Cameron Davison Date: Thu, 28 Jul 2016 22:49:19 -0500 Subject: [PATCH 1/5] code cleanup of inconsistent naming, spacing, and duplicate code --- command/status.go | 50 ++++++++++++++++++++++------------------------- commands.go | 2 -- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/command/status.go b/command/status.go index dcca9c1bd87..734c8591f69 100644 --- a/command/status.go +++ b/command/status.go @@ -20,8 +20,9 @@ const ( type StatusCommand struct { Meta - length int - showEvals, verbose bool + length int + evals bool + verbose bool } func (c *StatusCommand) Help() string { @@ -60,7 +61,7 @@ func (c *StatusCommand) Run(args []string) int { flags := c.Meta.FlagSet("status", FlagSetClient) flags.Usage = func() { c.Ui.Output(c.Help()) } flags.BoolVar(&short, "short", false, "") - flags.BoolVar(&c.showEvals, "evals", false, "") + flags.BoolVar(&c.evals, "evals", false, "") flags.BoolVar(&c.verbose, "verbose", false, "") if err := flags.Parse(args); err != nil { @@ -95,22 +96,12 @@ func (c *StatusCommand) Run(args []string) int { return 1 } - // No output if we have no jobs if len(jobs) == 0 { + // No output if we have no jobs c.Ui.Output("No running jobs") - return 0 + } else { + c.Ui.Output(createStatusListOutput(jobs)) } - - out := make([]string, len(jobs)+1) - out[0] = "ID|Type|Priority|Status" - for i, job := range jobs { - out[i+1] = fmt.Sprintf("%s|%s|%d|%s", - job.ID, - job.Type, - job.Priority, - job.Status) - } - c.Ui.Output(formatList(out)) return 0 } @@ -126,16 +117,7 @@ func (c *StatusCommand) Run(args []string) int { return 1 } if len(jobs) > 1 && strings.TrimSpace(jobID) != jobs[0].ID { - out := make([]string, len(jobs)+1) - out[0] = "ID|Type|Priority|Status" - for i, job := range jobs { - out[i+1] = fmt.Sprintf("%s|%s|%d|%s", - job.ID, - job.Type, - job.Priority, - job.Status) - } - c.Ui.Output(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", formatList(out))) + c.Ui.Output(fmt.Sprintf("Prefix matched multiple jobs\n\n%s", createStatusListOutput(jobs))) return 0 } // Prefix lookup matched a single job @@ -306,7 +288,7 @@ func (c *StatusCommand) outputJobInfo(client *api.Client, job *api.Job) error { } } - if c.verbose || c.showEvals { + if c.verbose || c.evals { c.Ui.Output(c.Colorize().Color("\n[bold]Evaluations[reset]")) c.Ui.Output(formatList(evals)) } @@ -379,3 +361,17 @@ func convertApiJob(in *api.Job) (*structs.Job, error) { } return structJob, nil } + +// list general information about a list of jobs +func createStatusListOutput(jobs []*structs.JobListStub) ([]string) { + out := make([]string, len(jobs)+1) + out[0] = "ID|Type|Priority|Status" + for i, job := range jobs { + out[i+1] = fmt.Sprintf("%s|%s|%d|%s", + job.ID, + job.Type, + job.Priority, + job.Status) + } + return formatList(out) +} \ No newline at end of file diff --git a/commands.go b/commands.go index acef7f16c67..372ed53755b 100644 --- a/commands.go +++ b/commands.go @@ -94,13 +94,11 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory { Meta: meta, }, nil }, - "plan": func() (cli.Command, error) { return &command.PlanCommand{ Meta: meta, }, nil }, - "run": func() (cli.Command, error) { return &command.RunCommand{ Meta: meta, From 40bc21fa8f46967fa513f6fffa78c814cea28ea5 Mon Sep 17 00:00:00 2001 From: Cameron Davison Date: Thu, 4 Aug 2016 20:36:22 -0500 Subject: [PATCH 2/5] add time flag to add created column to allocation --- command/status.go | 22 ++++++++++++++++++-- command/status_test.go | 47 +++++++++++++++++++++++++++++++++++++----- command/util_test.go | 2 +- commands.go | 2 ++ 4 files changed, 65 insertions(+), 8 deletions(-) diff --git a/command/status.go b/command/status.go index 734c8591f69..b82a17877ec 100644 --- a/command/status.go +++ b/command/status.go @@ -23,6 +23,7 @@ type StatusCommand struct { length int evals bool verbose bool + time bool } func (c *StatusCommand) Help() string { @@ -45,6 +46,9 @@ Status Options: -evals Display the evaluations associated with the job. + -time + Display allocation creation time. + -verbose Display full information. ` @@ -63,6 +67,7 @@ func (c *StatusCommand) Run(args []string) int { flags.BoolVar(&short, "short", false, "") flags.BoolVar(&c.evals, "evals", false, "") flags.BoolVar(&c.verbose, "verbose", false, "") + flags.BoolVar(&c.time, "time", false, "") if err := flags.Parse(args); err != nil { return 1 @@ -302,6 +307,9 @@ func (c *StatusCommand) outputJobInfo(client *api.Client, job *api.Job) error { if len(jobAllocs) > 0 { allocs = make([]string, len(jobAllocs)+1) allocs[0] = "ID|Eval ID|Node ID|Task Group|Desired|Status" + if c.time { + allocs[0] += "|Created" + } for i, alloc := range jobAllocs { allocs[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s", limit(alloc.ID, c.length), @@ -310,6 +318,10 @@ func (c *StatusCommand) outputJobInfo(client *api.Client, job *api.Job) error { alloc.TaskGroup, alloc.DesiredStatus, alloc.ClientStatus) + if c.time { + allocs[i+1] += fmt.Sprintf("|%s", + c.formatUnixNanoTime(alloc.CreateTime)) + } } c.Ui.Output(formatList(allocs)) @@ -346,6 +358,12 @@ func (c *StatusCommand) outputFailedPlacements(failedEval *api.Evaluation) { } } +// formatUnixNanoTime is a helper for formatting time for output. +func (c *StatusCommand) formatUnixNanoTime(nano int64) string { + t := time.Unix(0, nano) + return formatTime(t) +} + // convertApiJob is used to take a *api.Job and convert it to an *struct.Job. // This function is just a hammer and probably needs to be revisited. func convertApiJob(in *api.Job) (*structs.Job, error) { @@ -363,7 +381,7 @@ func convertApiJob(in *api.Job) (*structs.Job, error) { } // list general information about a list of jobs -func createStatusListOutput(jobs []*structs.JobListStub) ([]string) { +func createStatusListOutput(jobs []*api.JobListStub) string { out := make([]string, len(jobs)+1) out[0] = "ID|Type|Priority|Status" for i, job := range jobs { @@ -374,4 +392,4 @@ func createStatusListOutput(jobs []*structs.JobListStub) ([]string) { job.Status) } return formatList(out) -} \ No newline at end of file +} diff --git a/command/status_test.go b/command/status_test.go index 270d913571b..87cf98b893e 100644 --- a/command/status_test.go +++ b/command/status_test.go @@ -5,6 +5,8 @@ import ( "testing" "github.com/mitchellh/cli" + "github.com/hashicorp/nomad/testutil" + "github.com/hashicorp/nomad/api" ) func TestStatusCommand_Implements(t *testing.T) { @@ -12,7 +14,9 @@ func TestStatusCommand_Implements(t *testing.T) { } func TestStatusCommand_Run(t *testing.T) { - srv, client, url := testServer(t, nil) + srv, client, url := testServer(t, func(c *testutil.TestServerConfig) { + c.DevMode = true + }) defer srv.Stop() ui := new(cli.MockUi) @@ -33,14 +37,22 @@ func TestStatusCommand_Run(t *testing.T) { // Register two jobs job1 := testJob("job1_sfx") - evalId, _, err := client.Jobs().Register(job1, nil) + 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) + } + job2 := testJob("job2_sfx") - if _, _, err := client.Jobs().Register(job2, nil); err != nil { + evalId2, _, err := client.Jobs().Register(job2, nil); + if err != nil { t.Fatalf("err: %s", err) } + if code := waitForSuccess(ui, client, fullId, t, evalId2); code != 0 { + t.Fatalf("status code non zero saw %d", code) + } // Query again and check the result if code := cmd.Run([]string{"-address=" + url}); code != 0 { @@ -98,6 +110,25 @@ func TestStatusCommand_Run(t *testing.T) { if !strings.Contains(out, "Allocations") { t.Fatalf("should dump allocations") } + if strings.Contains(out, "Created") { + t.Fatal("should not have created header") + } + ui.OutputWriter.Reset() + + // Query a single job in time mode + if code := cmd.Run([]string{"-address=" + url, "-time", "job1_sfx"}); code != 0 { + t.Fatalf("expected exit 0, got: %d", code) + } + out = ui.OutputWriter.String() + if strings.Contains(out, "job2_sfx") || !strings.Contains(out, "job1_sfx") { + t.Fatalf("expected only job1_sfx, got: %s", out) + } + if !strings.Contains(out, "Allocations") { + t.Fatal("should dump allocations") + } + if !strings.Contains(out, "Created") { + t.Fatal("should have created header") + } ui.OutputWriter.Reset() // Query jobs with prefix match @@ -134,7 +165,7 @@ func TestStatusCommand_Run(t *testing.T) { if strings.Contains(out, "Allocations") { t.Fatalf("should not dump allocations") } - if strings.Contains(out, evalId) { + if strings.Contains(out, evalId1) { t.Fatalf("should not contain full identifiers, got %s", out) } ui.OutputWriter.Reset() @@ -144,7 +175,7 @@ func TestStatusCommand_Run(t *testing.T) { t.Fatalf("expected exit 0, got: %d", code) } out = ui.OutputWriter.String() - if !strings.Contains(out, evalId) { + if !strings.Contains(out, evalId1) { t.Fatalf("should contain full identifiers, got %s", out) } } @@ -170,3 +201,9 @@ func TestStatusCommand_Fails(t *testing.T) { t.Fatalf("expected failed query error, got: %s", out) } } + +func waitForSuccess(ui cli.Ui, client *api.Client, length int, t *testing.T, evalId string) int { + mon := newMonitor(ui, client, length) + monErr := mon.monitor(evalId, false) + return monErr +} \ No newline at end of file diff --git a/command/util_test.go b/command/util_test.go index 2eb2a743314..7671d933c14 100644 --- a/command/util_test.go +++ b/command/util_test.go @@ -39,7 +39,7 @@ func testServer( } func testJob(jobID string) *api.Job { - task := api.NewTask("task1", "exec"). + task := api.NewTask("task1", "raw_exec"). SetConfig("command", "/bin/sleep"). Require(&api.Resources{ MemoryMB: 256, diff --git a/commands.go b/commands.go index 372ed53755b..acef7f16c67 100644 --- a/commands.go +++ b/commands.go @@ -94,11 +94,13 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory { Meta: meta, }, nil }, + "plan": func() (cli.Command, error) { return &command.PlanCommand{ Meta: meta, }, nil }, + "run": func() (cli.Command, error) { return &command.RunCommand{ Meta: meta, From a66c568b3b9ee0b05b8f1aff9bcdeda848aa72ea Mon Sep 17 00:00:00 2001 From: Cameron Davison Date: Mon, 8 Aug 2016 21:15:24 -0500 Subject: [PATCH 3/5] remove time flag, and update docs with new column --- command/status.go | 19 +++---------- command/status_test.go | 24 +++------------- .../source/docs/commands/status.html.md.erb | 28 +++++++++---------- website/source/docs/jobops/inspecting.html.md | 16 +++++------ .../intro/getting-started/cluster.html.md | 8 +++--- .../source/intro/getting-started/jobs.html.md | 4 +-- 6 files changed, 36 insertions(+), 63 deletions(-) diff --git a/command/status.go b/command/status.go index b82a17877ec..24fc7833e20 100644 --- a/command/status.go +++ b/command/status.go @@ -23,7 +23,6 @@ type StatusCommand struct { length int evals bool verbose bool - time bool } func (c *StatusCommand) Help() string { @@ -46,9 +45,6 @@ Status Options: -evals Display the evaluations associated with the job. - -time - Display allocation creation time. - -verbose Display full information. ` @@ -67,7 +63,6 @@ func (c *StatusCommand) Run(args []string) int { flags.BoolVar(&short, "short", false, "") flags.BoolVar(&c.evals, "evals", false, "") flags.BoolVar(&c.verbose, "verbose", false, "") - flags.BoolVar(&c.time, "time", false, "") if err := flags.Parse(args); err != nil { return 1 @@ -306,22 +301,16 @@ func (c *StatusCommand) outputJobInfo(client *api.Client, job *api.Job) error { c.Ui.Output(c.Colorize().Color("\n[bold]Allocations[reset]")) if len(jobAllocs) > 0 { allocs = make([]string, len(jobAllocs)+1) - allocs[0] = "ID|Eval ID|Node ID|Task Group|Desired|Status" - if c.time { - allocs[0] += "|Created" - } + allocs[0] = "ID|Eval ID|Node ID|Task Group|Desired|Status|Created" for i, alloc := range jobAllocs { - allocs[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s", + allocs[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s|%s", limit(alloc.ID, c.length), limit(alloc.EvalID, c.length), limit(alloc.NodeID, c.length), alloc.TaskGroup, alloc.DesiredStatus, - alloc.ClientStatus) - if c.time { - allocs[i+1] += fmt.Sprintf("|%s", - c.formatUnixNanoTime(alloc.CreateTime)) - } + alloc.ClientStatus, + c.formatUnixNanoTime(alloc.CreateTime)) } c.Ui.Output(formatList(allocs)) diff --git a/command/status_test.go b/command/status_test.go index 87cf98b893e..d65f4455b1b 100644 --- a/command/status_test.go +++ b/command/status_test.go @@ -4,9 +4,9 @@ import ( "strings" "testing" - "github.com/mitchellh/cli" - "github.com/hashicorp/nomad/testutil" "github.com/hashicorp/nomad/api" + "github.com/hashicorp/nomad/testutil" + "github.com/mitchellh/cli" ) func TestStatusCommand_Implements(t *testing.T) { @@ -46,7 +46,7 @@ func TestStatusCommand_Run(t *testing.T) { } job2 := testJob("job2_sfx") - evalId2, _, err := client.Jobs().Register(job2, nil); + evalId2, _, err := client.Jobs().Register(job2, nil) if err != nil { t.Fatalf("err: %s", err) } @@ -110,22 +110,6 @@ func TestStatusCommand_Run(t *testing.T) { if !strings.Contains(out, "Allocations") { t.Fatalf("should dump allocations") } - if strings.Contains(out, "Created") { - t.Fatal("should not have created header") - } - ui.OutputWriter.Reset() - - // Query a single job in time mode - if code := cmd.Run([]string{"-address=" + url, "-time", "job1_sfx"}); code != 0 { - t.Fatalf("expected exit 0, got: %d", code) - } - out = ui.OutputWriter.String() - if strings.Contains(out, "job2_sfx") || !strings.Contains(out, "job1_sfx") { - t.Fatalf("expected only job1_sfx, got: %s", out) - } - if !strings.Contains(out, "Allocations") { - t.Fatal("should dump allocations") - } if !strings.Contains(out, "Created") { t.Fatal("should have created header") } @@ -206,4 +190,4 @@ func waitForSuccess(ui cli.Ui, client *api.Client, length int, t *testing.T, eva mon := newMonitor(ui, client, length) monErr := mon.monitor(evalId, false) return monErr -} \ No newline at end of file +} diff --git a/website/source/docs/commands/status.html.md.erb b/website/source/docs/commands/status.html.md.erb index a075ff9352c..05c6cf68efa 100644 --- a/website/source/docs/commands/status.html.md.erb +++ b/website/source/docs/commands/status.html.md.erb @@ -76,8 +76,8 @@ Status = running Periodic = false Allocations -ID Eval ID Node ID Task Group Desired Status -24cfd201 81efc2fa 8d0331e9 cache run running +ID Eval ID Node ID Task Group Desired Status Created +24cfd201 81efc2fa 8d0331e9 cache run running 08/08/16 21:03:19 CDT ``` Full status information of a job with placement failures: @@ -98,12 +98,12 @@ Task Group "cache": * Dimension "cpu exhausted" exhausted on 1 nodes Allocations -ID Eval ID Node ID Task Group Desired Status -0b8b9e37 8bf94335 8d0331e9 cache run running -b206088c 8bf94335 8d0331e9 cache run running -b82f58b6 8bf94335 8d0331e9 cache run running -ed3665f5 8bf94335 8d0331e9 cache run running -24cfd201 8bf94335 8d0331e9 cache run running +ID Eval ID Node ID Task Group Desired Status Created +0b8b9e37 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT +b206088c 8bf94335 8d0331e9 cache run running 08/08/16 21:03:18 CDT +b82f58b6 8bf94335 8d0331e9 cache run running 08/08/16 21:03:17 CDT +ed3665f5 8bf94335 8d0331e9 cache run running 08/08/16 21:03:21 CDT +24cfd201 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT ``` Full status information showing evaluations with a placement failure. The in @@ -133,10 +133,10 @@ Task Group "cache": * Dimension "cpu exhausted" exhausted on 1 nodes Allocations -ID Eval ID Node ID Task Group Desired Status -0b8b9e37 8bf94335 8d0331e9 cache run running -b206088c 8bf94335 8d0331e9 cache run running -b82f58b6 8bf94335 8d0331e9 cache run running -ed3665f5 8bf94335 8d0331e9 cache run running -24cfd201 8bf94335 8d0331e9 cache run running +ID Eval ID Node ID Task Group Desired Status Created +0b8b9e37 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT +b206088c 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT +b82f58b6 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT +ed3665f5 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT +24cfd201 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT ``` diff --git a/website/source/docs/jobops/inspecting.html.md b/website/source/docs/jobops/inspecting.html.md index 30bed5ae1f4..af0f5cd2b6d 100644 --- a/website/source/docs/jobops/inspecting.html.md +++ b/website/source/docs/jobops/inspecting.html.md @@ -39,14 +39,14 @@ Task Group "cache": * Dimension "cpu exhausted" exhausted on 1 nodes Allocations -ID Eval ID Node ID Task Group Desired Status -12681940 8e38e6cf 4beef22f cache run running -395c5882 8e38e6cf 4beef22f cache run running -4d7c6f84 8e38e6cf 4beef22f cache run running -843b07b8 8e38e6cf 4beef22f cache run running -a8bc6d3e 8e38e6cf 4beef22f cache run running -b0beb907 8e38e6cf 4beef22f cache run running -da21c1fd 8e38e6cf 4beef22f cache run running +ID Eval ID Node ID Task Group Desired Status Created +12681940 8e38e6cf 4beef22f cache run running 08/08/16 21:03:19 CDT +395c5882 8e38e6cf 4beef22f cache run running 08/08/16 21:03:19 CDT +4d7c6f84 8e38e6cf 4beef22f cache run running 08/08/16 21:03:19 CDT +843b07b8 8e38e6cf 4beef22f cache run running 08/08/16 21:03:19 CDT +a8bc6d3e 8e38e6cf 4beef22f cache run running 08/08/16 21:03:19 CDT +b0beb907 8e38e6cf 4beef22f cache run running 08/08/16 21:03:19 CDT +da21c1fd 8e38e6cf 4beef22f cache run running 08/08/16 21:03:19 CDT ``` In the above example we see that the job has a "blocked" evaluation that is in diff --git a/website/source/intro/getting-started/cluster.html.md b/website/source/intro/getting-started/cluster.html.md index bfa0edcdb6a..bf2fc25a2ab 100644 --- a/website/source/intro/getting-started/cluster.html.md +++ b/website/source/intro/getting-started/cluster.html.md @@ -185,10 +185,10 @@ Status = running Periodic = false Allocations -ID Eval ID Node ID Task Group Desired Status -501154ac 8e0a7cf9 c887deef cache run running -7e2b3900 8e0a7cf9 fca62612 cache run running -9c66fcaf 8e0a7cf9 c887deef cache run running +ID Eval ID Node ID Task Group Desired Status Created +501154ac 8e0a7cf9 c887deef cache run running 08/08/16 21:03:19 CDT +7e2b3900 8e0a7cf9 fca62612 cache run running 08/08/16 21:03:19 CDT +9c66fcaf 8e0a7cf9 c887deef cache run running 08/08/16 21:03:19 CDT ``` We can see that all our tasks have been allocated and are running. diff --git a/website/source/intro/getting-started/jobs.html.md b/website/source/intro/getting-started/jobs.html.md index 3630ba1965f..bdedfb35d31 100644 --- a/website/source/intro/getting-started/jobs.html.md +++ b/website/source/intro/getting-started/jobs.html.md @@ -71,8 +71,8 @@ Status = running Periodic = false Allocations -ID Eval ID Node ID Task Group Desired Status -dadcdb81 61b0b423 72687b1a cache run running +ID Eval ID Node ID Task Group Desired Status Created +dadcdb81 61b0b423 72687b1a cache run running 06/23/16 01:41:13 UTC ``` Here we can see that the result of our evaluation was the creation of an From 0b7acd582596737260c44952d362b1881adc744b Mon Sep 17 00:00:00 2001 From: Cameron Davison Date: Mon, 8 Aug 2016 21:24:38 -0500 Subject: [PATCH 4/5] move formatUnixNanoTime into a utility function --- command/alloc_status.go | 10 ++-------- command/helpers.go | 6 ++++++ command/status.go | 8 +------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/command/alloc_status.go b/command/alloc_status.go index ebf83163eb0..c5f43451bf1 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -194,7 +194,7 @@ func (c *AllocStatusCommand) outputTaskStatus(state *api.TaskState) { size := len(state.Events) for i, event := range state.Events { - formatedTime := c.formatUnixNanoTime(event.Time) + formatedTime := formatUnixNanoTime(event.Time) // Build up the description based on the event type. var desc string @@ -400,7 +400,7 @@ func (c *AllocStatusCommand) shortTaskStatus(alloc *api.Allocation) { if l != 0 { last := state.Events[l-1] lastEvent = last.Type - lastTime = c.formatUnixNanoTime(last.Time) + lastTime = formatUnixNanoTime(last.Time) } tasks = append(tasks, fmt.Sprintf("%s|%s|%s|%s", @@ -430,9 +430,3 @@ func (c *AllocStatusCommand) sortedTaskStateIterator(m map[string]*api.TaskState close(output) return output } - -// formatUnixNanoTime is a helper for formating time for output. -func (c *AllocStatusCommand) formatUnixNanoTime(nano int64) string { - t := time.Unix(0, nano) - return formatTime(t) -} diff --git a/command/helpers.go b/command/helpers.go index b9c4a6be7af..123f4b70e0a 100644 --- a/command/helpers.go +++ b/command/helpers.go @@ -51,6 +51,12 @@ func formatTime(t time.Time) string { return t.Format("01/02/06 15:04:05 MST") } +// formatUnixNanoTime is a helper for formatting time for output. +func formatUnixNanoTime(nano int64) string { + t := time.Unix(0, nano) + return formatTime(t) +} + // formatTimeDifference takes two times and determines their duration difference // truncating to a passed unit. // E.g. formatTimeDifference(first=1m22s33ms, second=1m28s55ms, time.Second) -> 6s diff --git a/command/status.go b/command/status.go index 24fc7833e20..808e7507e50 100644 --- a/command/status.go +++ b/command/status.go @@ -310,7 +310,7 @@ func (c *StatusCommand) outputJobInfo(client *api.Client, job *api.Job) error { alloc.TaskGroup, alloc.DesiredStatus, alloc.ClientStatus, - c.formatUnixNanoTime(alloc.CreateTime)) + formatUnixNanoTime(alloc.CreateTime)) } c.Ui.Output(formatList(allocs)) @@ -347,12 +347,6 @@ func (c *StatusCommand) outputFailedPlacements(failedEval *api.Evaluation) { } } -// formatUnixNanoTime is a helper for formatting time for output. -func (c *StatusCommand) formatUnixNanoTime(nano int64) string { - t := time.Unix(0, nano) - return formatTime(t) -} - // convertApiJob is used to take a *api.Job and convert it to an *struct.Job. // This function is just a hammer and probably needs to be revisited. func convertApiJob(in *api.Job) (*structs.Job, error) { From 561d7e3e974da77f7c9e5a6fb14b1119041c7925 Mon Sep 17 00:00:00 2001 From: Cameron Davison Date: Mon, 15 Aug 2016 21:40:34 -0500 Subject: [PATCH 5/5] s/Created/Created At/ --- command/status.go | 2 +- command/status_test.go | 2 +- website/source/docs/commands/status.html.md.erb | 6 +++--- website/source/docs/jobops/inspecting.html.md | 2 +- website/source/intro/getting-started/cluster.html.md | 2 +- website/source/intro/getting-started/jobs.html.md | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/command/status.go b/command/status.go index 808e7507e50..8b94997a585 100644 --- a/command/status.go +++ b/command/status.go @@ -301,7 +301,7 @@ func (c *StatusCommand) outputJobInfo(client *api.Client, job *api.Job) error { c.Ui.Output(c.Colorize().Color("\n[bold]Allocations[reset]")) if len(jobAllocs) > 0 { allocs = make([]string, len(jobAllocs)+1) - allocs[0] = "ID|Eval ID|Node ID|Task Group|Desired|Status|Created" + allocs[0] = "ID|Eval ID|Node ID|Task Group|Desired|Status|Created At" for i, alloc := range jobAllocs { allocs[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s|%s", limit(alloc.ID, c.length), diff --git a/command/status_test.go b/command/status_test.go index d65f4455b1b..6d6801b6dd5 100644 --- a/command/status_test.go +++ b/command/status_test.go @@ -110,7 +110,7 @@ func TestStatusCommand_Run(t *testing.T) { if !strings.Contains(out, "Allocations") { t.Fatalf("should dump allocations") } - if !strings.Contains(out, "Created") { + if !strings.Contains(out, "Created At") { t.Fatal("should have created header") } ui.OutputWriter.Reset() diff --git a/website/source/docs/commands/status.html.md.erb b/website/source/docs/commands/status.html.md.erb index 05c6cf68efa..cb280a848e4 100644 --- a/website/source/docs/commands/status.html.md.erb +++ b/website/source/docs/commands/status.html.md.erb @@ -76,7 +76,7 @@ Status = running Periodic = false Allocations -ID Eval ID Node ID Task Group Desired Status Created +ID Eval ID Node ID Task Group Desired Status Created At 24cfd201 81efc2fa 8d0331e9 cache run running 08/08/16 21:03:19 CDT ``` @@ -98,7 +98,7 @@ Task Group "cache": * Dimension "cpu exhausted" exhausted on 1 nodes Allocations -ID Eval ID Node ID Task Group Desired Status Created +ID Eval ID Node ID Task Group Desired Status Created At 0b8b9e37 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT b206088c 8bf94335 8d0331e9 cache run running 08/08/16 21:03:18 CDT b82f58b6 8bf94335 8d0331e9 cache run running 08/08/16 21:03:17 CDT @@ -133,7 +133,7 @@ Task Group "cache": * Dimension "cpu exhausted" exhausted on 1 nodes Allocations -ID Eval ID Node ID Task Group Desired Status Created +ID Eval ID Node ID Task Group Desired Status Created At 0b8b9e37 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT b206088c 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT b82f58b6 8bf94335 8d0331e9 cache run running 08/08/16 21:03:19 CDT diff --git a/website/source/docs/jobops/inspecting.html.md b/website/source/docs/jobops/inspecting.html.md index af0f5cd2b6d..9b18f2cfd98 100644 --- a/website/source/docs/jobops/inspecting.html.md +++ b/website/source/docs/jobops/inspecting.html.md @@ -39,7 +39,7 @@ Task Group "cache": * Dimension "cpu exhausted" exhausted on 1 nodes Allocations -ID Eval ID Node ID Task Group Desired Status Created +ID Eval ID Node ID Task Group Desired Status Created At 12681940 8e38e6cf 4beef22f cache run running 08/08/16 21:03:19 CDT 395c5882 8e38e6cf 4beef22f cache run running 08/08/16 21:03:19 CDT 4d7c6f84 8e38e6cf 4beef22f cache run running 08/08/16 21:03:19 CDT diff --git a/website/source/intro/getting-started/cluster.html.md b/website/source/intro/getting-started/cluster.html.md index bf2fc25a2ab..31535df93f0 100644 --- a/website/source/intro/getting-started/cluster.html.md +++ b/website/source/intro/getting-started/cluster.html.md @@ -185,7 +185,7 @@ Status = running Periodic = false Allocations -ID Eval ID Node ID Task Group Desired Status Created +ID Eval ID Node ID Task Group Desired Status Created At 501154ac 8e0a7cf9 c887deef cache run running 08/08/16 21:03:19 CDT 7e2b3900 8e0a7cf9 fca62612 cache run running 08/08/16 21:03:19 CDT 9c66fcaf 8e0a7cf9 c887deef cache run running 08/08/16 21:03:19 CDT diff --git a/website/source/intro/getting-started/jobs.html.md b/website/source/intro/getting-started/jobs.html.md index bdedfb35d31..4acaeaa0984 100644 --- a/website/source/intro/getting-started/jobs.html.md +++ b/website/source/intro/getting-started/jobs.html.md @@ -71,7 +71,7 @@ Status = running Periodic = false Allocations -ID Eval ID Node ID Task Group Desired Status Created +ID Eval ID Node ID Task Group Desired Status Created At dadcdb81 61b0b423 72687b1a cache run running 06/23/16 01:41:13 UTC ```