Don't fail if task dirs don't exist on creation
Task dir metadata is created in AllocRunner.Run which may not run before an alloc is sync'd and Nomad exits. There's no reason not to just create task dir metadata on restore if it doesn't exist.
This commit is contained in:
parent
51515cbe0c
commit
98f6e7f10f
|
@ -284,10 +284,11 @@ func (r *AllocRunner) RestoreState() error {
|
|||
|
||||
td, ok := r.allocDir.TaskDirs[name]
|
||||
if !ok {
|
||||
err := fmt.Errorf("failed to find task dir metadata for alloc %q task %q",
|
||||
r.alloc.ID, name)
|
||||
r.logger.Printf("[ERR] client: %v", err)
|
||||
return err
|
||||
// Create the task dir metadata if it doesn't exist.
|
||||
// Since task dirs are created during r.Run() the
|
||||
// client may save state and exit before all task dirs
|
||||
// are created
|
||||
td = r.allocDir.NewTaskDir(name)
|
||||
}
|
||||
|
||||
tr := NewTaskRunner(r.logger, r.config, r.stateDB, r.setTaskState, td, r.Alloc(), task, r.vaultClient, r.consulClient)
|
||||
|
|
Loading…
Reference in a new issue