Skip to content

Commit 0f7bb8c

Browse files
committed
[wip]
1 parent 867e796 commit 0f7bb8c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

allocrunnersim/allocrunnersim.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func (ar *simulatedAllocRunner) stopAll() {
345345
// Ensure we have a current copy of the task states, so that we append and
346346
// create a correct and full list.
347347
ar.allocStateLock.RLock()
348-
taskStates := ar.allocState.TaskStates
348+
taskStates := ar.allocState.Copy().TaskStates
349349
ar.allocStateLock.RUnlock()
350350

351351
// Perform the task kill, which essentially is the shutdown notification.
@@ -360,8 +360,11 @@ func (ar *simulatedAllocRunner) stopAll() {
360360
event.PopulateEventDisplayMessage()
361361
taskStates[task.Name].Events = append(taskStates[task.Name].Events, event)
362362
}
363-
ar.updateAllocAndSendUpdate(taskStates)
363+
ar.allocStateLock.Lock()
364+
ar.allocState.Copy().TaskStates = taskStates
365+
ar.allocStateLock.Unlock()
364366

367+
ar.updateAllocAndSendUpdate(taskStates)
365368
// Mark the tasks as killed and ensure the state is updated to show they
366369
// are dead and finished.
367370
time.Sleep(200 * time.Millisecond)
@@ -379,6 +382,7 @@ func (ar *simulatedAllocRunner) stopAll() {
379382
ar.allocStateLock.Lock()
380383
ar.allocState.TaskStates[task.Name].FinishedAt = time.Now()
381384
ar.allocState.TaskStates[task.Name].State = structs.TaskStateDead
385+
382386
ar.allocStateLock.Unlock()
383387
}
384388
ar.updateAllocAndSendUpdate(taskStates)

0 commit comments

Comments
 (0)