From 9ebc143345451ea85273193c4395611d18277f64 Mon Sep 17 00:00:00 2001 From: Abhishek Chanda Date: Tue, 5 Jan 2016 10:27:44 +0000 Subject: [PATCH] Mount task and alloc dirs in the rkt driver rkt docs herer https://coreos.com/rkt/docs/latest/subcommands/run.html#mounting-volumes --- client/driver/rkt.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/driver/rkt.go b/client/driver/rkt.go index 19509f2ad75..143d4c4d36f 100644 --- a/client/driver/rkt.go +++ b/client/driver/rkt.go @@ -149,9 +149,8 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e // Inject the environment variables. envVars := TaskEnvironmentVariables(ctx, task) - // Clear the task directories as they are not currently supported. - envVars.ClearTaskLocalDir() - envVars.ClearAllocDir() + envVars.SetAllocDir(filepath.Join("/", allocdir.SharedAllocName)) + envVars.SetTaskLocalDir(filepath.Join("/", allocdir.TaskLocal)) for k, v := range envVars.Map() { cmdArgs = append(cmdArgs, fmt.Sprintf("--set-env=%v=%v", k, v)) @@ -160,6 +159,13 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e // Append the run command. cmdArgs = append(cmdArgs, "run", "--mds-register=false", img) + // Mount allc and task dirs + local, ok := ctx.AllocDir.TaskDirs[task.Name] + if !ok { + return nil, fmt.Errorf("Failed to find task local directory: %v", task.Name) + } + cmdArgs = append(cmdArgs, fmt.Sprintf("--volume %s,kind=empty,readOnly=false,source=%s --mount volume=data,target=%s", task.Name, local, ctx.AllocDir.SharedDir)) + // Check if the user has overriden the exec command. if execCmd, ok := task.Config["command"]; ok { cmdArgs = append(cmdArgs, fmt.Sprintf("--exec=%v", execCmd))