From 7f608add4f0b3ae263d214bfccdefa25d254faed Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Wed, 14 Sep 2016 18:27:13 -0700 Subject: [PATCH] alloc-status --- api/tasks.go | 6 ++++++ command/alloc_status.go | 18 ++++++++++++++++++ nomad/structs/structs.go | 9 +++++---- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/api/tasks.go b/api/tasks.go index 6b37356ce..8eaefc412 100644 --- a/api/tasks.go +++ b/api/tasks.go @@ -233,6 +233,8 @@ const ( TaskDownloadingArtifacts = "Downloading Artifacts" TaskArtifactDownloadFailed = "Failed Artifact Download" TaskDiskExceeded = "Disk Exceeded" + TaskVaultRenewalFailed = "Vault token renewal failed" + TaskSiblingFailed = "Sibling task failed" ) // TaskEvent is an event that effects the state of a task and contains meta-data @@ -250,4 +252,8 @@ type TaskEvent struct { StartDelay int64 DownloadError string ValidationError string + DiskLimit int64 + DiskSize int64 + FailedSibling string + VaultError string } diff --git a/command/alloc_status.go b/command/alloc_status.go index b3177044b..15b6419bc 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -335,6 +335,24 @@ func (c *AllocStatusCommand) outputTaskStatus(state *api.TaskState) { } else { desc = "Task exceeded restart policy" } + case api.TaskDiskExceeded: + if event.DiskLimit != 0 && event.DiskSize != 0 { + desc = fmt.Sprintf("Disk size exceeded maximum: %d > %d", event.DiskSize, event.DiskLimit) + } else { + desc = "Task exceeded disk quota" + } + case api.TaskVaultRenewalFailed: + if event.VaultError != "" { + desc = event.VaultError + } else { + desc = "Task's Vault token failed to be renewed" + } + case api.TaskSiblingFailed: + if event.FailedSibling != "" { + desc = fmt.Sprintf("Task's sibling %q failed", event.FailedSibling) + } else { + desc = "Task's sibling failed" + } } // Reverse order so we are sorted by time diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 01cdd8d9a..2e8e0ce69 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -2209,7 +2209,8 @@ func (ts *TaskState) Failed() bool { } switch ts.Events[l-1].Type { - case TaskDiskExceeded, TaskNotRestarting, TaskArtifactDownloadFailed, TaskFailedValidation: + case TaskDiskExceeded, TaskNotRestarting, TaskArtifactDownloadFailed, + TaskFailedValidation, TaskVaultRenewalFailed: return true default: return false @@ -2326,8 +2327,8 @@ type TaskEvent struct { // the TaskEvent refers to. FailedSibling string - // VaultErr is the error from token renewal - VaultErr string + // VaultError is the error from token renewal + VaultError string } func (te *TaskEvent) GoString() string { @@ -2427,7 +2428,7 @@ func (e *TaskEvent) SetFailedSibling(sibling string) *TaskEvent { func (e *TaskEvent) SetVaultRenewalError(err error) *TaskEvent { if err != nil { - e.VaultErr = err.Error() + e.VaultError = err.Error() } return e }