mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 08:55:43 +03:00
Fix the capacity
This commit is contained in:
@@ -130,7 +130,7 @@ const (
|
||||
type TaskEvent struct {
|
||||
Type string
|
||||
Time int64
|
||||
DriverError error
|
||||
DriverError string
|
||||
ExitCode int
|
||||
Signal int
|
||||
Message string
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user