From ec1b44e7e693a9dd5bc55b1b5db25cfa860ce3f7 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Thu, 13 Oct 2016 16:18:18 -0700 Subject: [PATCH] Fix standard mounts in rkt and tests --- client/driver/rkt.go | 25 ++++++++++++++++++++++--- client/driver/rkt_test.go | 6 +++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/client/driver/rkt.go b/client/driver/rkt.go index ac422ec6e..5530cb4e5 100644 --- a/client/driver/rkt.go +++ b/client/driver/rkt.go @@ -43,6 +43,10 @@ const ( // The key populated in the Node Attributes to indicate the presence of the // Rkt driver rktDriverAttr = "driver.rkt" + + // rktVolumesConfigOption is the key for enabling the use of custom + // bind volumes. + rktVolumesConfigOption = "rkt.volumes.enabled" ) // RktDriver is a driver for running images via Rkt @@ -211,15 +215,30 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e insecure = true } cmdArgs = append(cmdArgs, "run") - cmdArgs = append(cmdArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s", task.Name, ctx.AllocDir.SharedDir)) - cmdArgs = append(cmdArgs, fmt.Sprintf("--mount=volume=%s,target=%s", task.Name, ctx.AllocDir.SharedDir)) + + // Mount /alloc + cmdArgs = append(cmdArgs, fmt.Sprintf("--volume=%salloc,kind=host,source=%s", task.Name, ctx.AllocDir.SharedDir)) + cmdArgs = append(cmdArgs, fmt.Sprintf("--mount=volume=%salloc,target=%s", task.Name, allocdir.SharedAllocContainerPath)) + + // Mount /local + cmdArgs = append(cmdArgs, fmt.Sprintf("--volume=%slocal,kind=host,source=%s", task.Name, filepath.Join(taskDir, allocdir.TaskLocal))) + cmdArgs = append(cmdArgs, fmt.Sprintf("--mount=volume=%slocal,target=%s", task.Name, allocdir.TaskLocalContainerPath)) + + // Mount /secrets + cmdArgs = append(cmdArgs, fmt.Sprintf("--volume=%ssecrets,kind=host,source=%s", task.Name, filepath.Join(taskDir, allocdir.TaskSecrets))) + cmdArgs = append(cmdArgs, fmt.Sprintf("--mount=volume=%ssecrets,target=/%s", task.Name, allocdir.TaskSecretsContainerPath)) + cmdArgs = append(cmdArgs, img) - if insecure == true { + if insecure { cmdArgs = append(cmdArgs, "--insecure-options=all") } cmdArgs = append(cmdArgs, fmt.Sprintf("--debug=%t", debug)) // Inject environment variables + d.taskEnv.SetAllocDir(allocdir.SharedAllocContainerPath) + d.taskEnv.SetTaskLocalDir(allocdir.TaskLocalContainerPath) + d.taskEnv.SetTaskLocalDir(allocdir.TaskSecretsContainerPath) + d.taskEnv.Build() for k, v := range d.taskEnv.EnvMap() { cmdArgs = append(cmdArgs, fmt.Sprintf("--set-env=%v=%v", k, v)) } diff --git a/client/driver/rkt_test.go b/client/driver/rkt_test.go index 6418320e3..731f8f089 100644 --- a/client/driver/rkt_test.go +++ b/client/driver/rkt_test.go @@ -171,7 +171,7 @@ func TestRktDriver_Start_Wait(t *testing.T) { if !res.Successful() { t.Fatalf("err: %v", res) } - case <-time.After(time.Duration(testutil.TestMultiplier()*5) * time.Second): + case <-time.After(time.Duration(testutil.TestMultiplier()*15) * time.Second): t.Fatalf("timeout") } } @@ -223,7 +223,7 @@ func TestRktDriver_Start_Wait_Skip_Trust(t *testing.T) { if !res.Successful() { t.Fatalf("err: %v", res) } - case <-time.After(time.Duration(testutil.TestMultiplier()*5) * time.Second): + case <-time.After(time.Duration(testutil.TestMultiplier()*15) * time.Second): t.Fatalf("timeout") } } @@ -276,7 +276,7 @@ func TestRktDriver_Start_Wait_AllocDir(t *testing.T) { if !res.Successful() { t.Fatalf("err: %v", res) } - case <-time.After(time.Duration(testutil.TestMultiplier()*5) * time.Second): + case <-time.After(time.Duration(testutil.TestMultiplier()*15) * time.Second): t.Fatalf("timeout") }