diff --git a/api/tasks.go b/api/tasks.go index 548906ae2..2eb77f935 100644 --- a/api/tasks.go +++ b/api/tasks.go @@ -130,7 +130,7 @@ const ( type TaskEvent struct { Type string Time int64 - DriverError error + DriverError string ExitCode int Signal int Message string diff --git a/client/alloc_runner.go b/client/alloc_runner.go index ebbb0801c..d723478db 100644 --- a/client/alloc_runner.go +++ b/client/alloc_runner.go @@ -183,16 +183,6 @@ func (r *AllocRunner) Alloc() *structs.Allocation { return r.alloc } -// setAlloc is used to update the allocation of the runner -// we preserve the existing client status and description -func (r *AllocRunner) setAlloc(alloc *structs.Allocation) { - if r.alloc != nil { - alloc.ClientStatus = r.alloc.ClientStatus - alloc.ClientDescription = r.alloc.ClientDescription - } - r.alloc = alloc -} - // dirtySyncState is used to watch for state being marked dirty to sync func (r *AllocRunner) dirtySyncState() { for { diff --git a/client/task_runner.go b/client/task_runner.go index b2a2f46d4..936ccecbf 100644 --- a/client/task_runner.go +++ b/client/task_runner.go @@ -137,11 +137,27 @@ func (r *TaskRunner) DestroyState() error { return os.RemoveAll(r.stateFilePath()) } +func (r *TaskRunner) appendEvent(event *structs.TaskEvent) { + capacity := 10 + if r.state.Events == nil { + r.state.Events = make([]*structs.TaskEvent, 0, capacity) + } + + // If we hit capacity, then shift it. + if len(r.state.Events) == capacity { + old := r.state.Events + r.state.Events = make([]*structs.TaskEvent, 0, capacity) + r.state.Events = append(r.state.Events, old[1:]...) + } + + r.state.Events = append(r.state.Events, event) +} + // setState is used to update the state of the task runner func (r *TaskRunner) setState(state string, event *structs.TaskEvent) { // Update the task. r.state.State = state - r.state.Events = append(r.state.Events, event) + r.appendEvent(event) // Persist our state to disk. if err := r.SaveState(); err != nil { @@ -278,6 +294,7 @@ OUTER: // Recurse on ourselves and force the start since we are restarting the task. r.run(true) + // TODO: Alex return }