Fix TestAllocRunner_SaveRestoreState

This commit is contained in:
Alex Dadgar
2017-03-02 20:45:46 -08:00
parent 94974152fd
commit fbfeecb486
2 changed files with 10 additions and 4 deletions

View File

@@ -321,7 +321,8 @@ func TestAllocRunner_SaveRestoreState(t *testing.T) {
}
// Create a new alloc runner
ar2 := NewAllocRunner(ar.logger, ar.config, upd.Update,
l2 := prefixedTestLogger("----- ar2: ")
ar2 := NewAllocRunner(l2, ar.config, upd.Update,
&structs.Allocation{ID: ar.alloc.ID}, ar.vaultClient)
err = ar2.RestoreState()
if err != nil {
@@ -341,7 +342,7 @@ func TestAllocRunner_SaveRestoreState(t *testing.T) {
last := upd.Allocs[upd.Count-1]
return last.ClientStatus == structs.AllocClientStatusRunning, nil
}, func(err error) {
t.Fatalf("err: %v %#v %#v", err, upd.Allocs[0], ar.alloc.TaskStates)
t.Fatalf("err: %v %#v %#v", err, upd.Allocs[0], ar2.alloc.TaskStates["web"])
})
// Destroy and wait

View File

@@ -1212,8 +1212,13 @@ func (r *TaskRunner) buildTaskDir(fsi cstructs.FSIsolation) error {
built := r.taskDirBuilt
r.persistLock.Unlock()
r.setState(structs.TaskStatePending, structs.NewTaskEvent(structs.TaskSetup).
SetMessage(structs.TaskBuildingTaskDir))
// We do not set the state again since this only occurs during restoration
// and the task dir is already built. The reason we call Build again is to
// ensure that the task dir invariants are still held.
if !built {
r.setState(structs.TaskStatePending, structs.NewTaskEvent(structs.TaskSetup).
SetMessage(structs.TaskBuildingTaskDir))
}
chroot := config.DefaultChrootEnv
if len(r.config.ChrootEnv) > 0 {