mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
plan displays launch time of periodic jobs
This commit is contained in:
@@ -46,7 +46,7 @@ func limit(s string, length int) string {
|
||||
|
||||
// formatTime formats the time to string based on RFC822
|
||||
func formatTime(t time.Time) string {
|
||||
return t.Format("02/01/06 15:04:05 MST")
|
||||
return t.Format("01/02/06 15:04:05 MST")
|
||||
}
|
||||
|
||||
// getLocalNodeID returns the node ID of the local Nomad Client and an error if
|
||||
|
||||
@@ -139,7 +139,7 @@ func (c *PlanCommand) Run(args []string) int {
|
||||
|
||||
// Print the scheduler dry-run output
|
||||
c.Ui.Output(c.Colorize().Color("[bold]Scheduler dry-run:[reset]"))
|
||||
c.Ui.Output(c.Colorize().Color(formatDryRun(resp.FailedTGAllocs, resp.CreatedEvals)))
|
||||
c.Ui.Output(c.Colorize().Color(formatDryRun(resp)))
|
||||
c.Ui.Output("")
|
||||
|
||||
// Print the job index info
|
||||
@@ -156,22 +156,22 @@ func formatJobModifyIndex(jobModifyIndex uint64, jobName string) string {
|
||||
}
|
||||
|
||||
// formatDryRun produces a string explaining the results of the dry run.
|
||||
func formatDryRun(failedTGAllocs map[string]*api.AllocationMetric, evals []*api.Evaluation) string {
|
||||
func formatDryRun(resp *api.JobPlanResponse) string {
|
||||
var rolling *api.Evaluation
|
||||
for _, eval := range evals {
|
||||
for _, eval := range resp.CreatedEvals {
|
||||
if eval.TriggeredBy == "rolling-update" {
|
||||
rolling = eval
|
||||
}
|
||||
}
|
||||
|
||||
var out string
|
||||
if len(failedTGAllocs) == 0 {
|
||||
if len(resp.FailedTGAllocs) == 0 {
|
||||
out = "[bold][green]- All tasks successfully allocated.[reset]\n"
|
||||
} else {
|
||||
out = "[bold][yellow]- WARNING: Failed to place all allocations.[reset]\n"
|
||||
sorted := sortedTaskGroupFromMetrics(failedTGAllocs)
|
||||
sorted := sortedTaskGroupFromMetrics(resp.FailedTGAllocs)
|
||||
for _, tg := range sorted {
|
||||
metrics := failedTGAllocs[tg]
|
||||
metrics := resp.FailedTGAllocs[tg]
|
||||
|
||||
noun := "allocation"
|
||||
if metrics.CoalescedFailures > 0 {
|
||||
@@ -189,6 +189,10 @@ func formatDryRun(failedTGAllocs map[string]*api.AllocationMetric, evals []*api.
|
||||
out += fmt.Sprintf("[green]- Rolling update, next evaluation will be in %s.\n", rolling.Wait)
|
||||
}
|
||||
|
||||
if !resp.NextPeriodicLaunch.IsZero() {
|
||||
out += fmt.Sprintf("[green]- If submitted now, next periodic launch would be at %s.\n", formatTime(resp.NextPeriodicLaunch))
|
||||
}
|
||||
|
||||
out = strings.TrimSuffix(out, "\n")
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ func (c *RunCommand) Run(args []string) int {
|
||||
if detach || periodic {
|
||||
c.Ui.Output("Job registration successful")
|
||||
if periodic {
|
||||
c.Ui.Output(fmt.Sprintf("Approximate next launch time: %v", job.Periodic.Next(time.Now().UTC())))
|
||||
c.Ui.Output(fmt.Sprintf("Approximate next launch time: %v", formatTime(job.Periodic.Next(time.Now().UTC()))))
|
||||
} else {
|
||||
c.Ui.Output("Evaluation ID: " + evalID)
|
||||
}
|
||||
|
||||
@@ -164,8 +164,8 @@ func (c *StatusCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
if periodic {
|
||||
basic = append(basic, fmt.Sprintf("Next Periodic Launch|%v",
|
||||
sJob.Periodic.Next(time.Now().UTC())))
|
||||
basic = append(basic, fmt.Sprintf("Next Periodic Launch|%s",
|
||||
formatTime(sJob.Periodic.Next(time.Now().UTC()))))
|
||||
}
|
||||
|
||||
c.Ui.Output(formatKV(basic))
|
||||
|
||||
Reference in New Issue
Block a user