From 427a0ae1dbb07a9d6981e00ff1edf333ec7bf360 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Fri, 14 Jul 2017 13:45:01 -0700 Subject: [PATCH] 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. --- client/alloc_runner.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/alloc_runner.go b/client/alloc_runner.go index 536a350df..d5a749087 100644 --- a/client/alloc_runner.go +++ b/client/alloc_runner.go @@ -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)