From 66f59e2dc0c9a266159498cfa94b5beab7ff2b0c Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Thu, 4 Feb 2016 15:35:04 -0800 Subject: [PATCH] Add tmp file to each task directory --- client/allocdir/alloc_dir.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/allocdir/alloc_dir.go b/client/allocdir/alloc_dir.go index e5200be41..ab56f6982 100644 --- a/client/allocdir/alloc_dir.go +++ b/client/allocdir/alloc_dir.go @@ -21,6 +21,9 @@ var ( // The name of the directory that exists inside each task directory // regardless of driver. TaskLocal = "local" + + // TaskDirs is the set of directories created in each tasks directory. + TaskDirs = []string{"tmp"} ) type AllocDir struct { @@ -120,6 +123,18 @@ func (d *AllocDir) Build(tasks []*structs.Task) error { } d.TaskDirs[t.Name] = taskDir + + // Create the directories that should be in every task. + for _, dir := range TaskDirs { + local := filepath.Join(taskDir, dir) + if err := os.Mkdir(local, 0777); err != nil { + return err + } + + if err := d.dropDirPermissions(local); err != nil { + return err + } + } } return nil