alloc-status

This commit is contained in:
Alex Dadgar 2016-09-14 18:27:13 -07:00
parent ec152a6d12
commit ada5d8dd0c
3 changed files with 29 additions and 4 deletions

View file

@ -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
}

View file

@ -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

View file

@ -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
}