diff --git a/client/driver/exec.go b/client/driver/exec.go index fb24f021f..191175d78 100644 --- a/client/driver/exec.go +++ b/client/driver/exec.go @@ -4,11 +4,9 @@ import ( "encoding/json" "fmt" "log" - "path/filepath" "syscall" "time" - "github.com/hashicorp/nomad/client/allocdir" "github.com/hashicorp/nomad/client/config" "github.com/hashicorp/nomad/client/driver/executor" cstructs "github.com/hashicorp/nomad/client/driver/structs" @@ -84,7 +82,7 @@ func (d *ExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, if ok && source != "" { // Proceed to download an artifact to be executed. _, err := getter.GetArtifact( - filepath.Join(taskDir, allocdir.TaskLocal), + taskDir, driverConfig.ArtifactSource, driverConfig.Checksum, d.logger, diff --git a/client/driver/exec_test.go b/client/driver/exec_test.go index 5b077e9d6..1f1404289 100644 --- a/client/driver/exec_test.go +++ b/client/driver/exec_test.go @@ -123,7 +123,7 @@ func TestExecDriver_Start_Artifact_basic(t *testing.T) { Name: "sleep", Config: map[string]interface{}{ "artifact_source": fmt.Sprintf("https://dl.dropboxusercontent.com/u/47675/jar_thing/%s?checksum=%s", file, checksum), - "command": filepath.Join("$NOMAD_TASK_DIR", file), + "command": file, }, Resources: basicResources, } @@ -167,10 +167,7 @@ func TestExecDriver_Start_Artifact_expanded(t *testing.T) { Config: map[string]interface{}{ "artifact_source": fmt.Sprintf("https://dl.dropboxusercontent.com/u/47675/jar_thing/%s", file), "command": "/bin/bash", - "args": []string{ - "-c", - fmt.Sprintf(`/bin/sleep 1 && %s`, filepath.Join("$NOMAD_TASK_DIR", file)), - }, + "args": []string{"-c", fmt.Sprintf("/bin/sleep 1 && %s", file)}, }, Resources: basicResources, } diff --git a/client/driver/java.go b/client/driver/java.go index 3cb32679c..32170bcbd 100644 --- a/client/driver/java.go +++ b/client/driver/java.go @@ -114,7 +114,7 @@ func (d *JavaDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, // Proceed to download an artifact to be executed. path, err := getter.GetArtifact( - filepath.Join(taskDir, allocdir.TaskLocal), + taskDir, driverConfig.ArtifactSource, driverConfig.Checksum, d.logger, diff --git a/client/driver/qemu.go b/client/driver/qemu.go index df36b4cd3..4235517e0 100644 --- a/client/driver/qemu.go +++ b/client/driver/qemu.go @@ -11,7 +11,6 @@ import ( "strings" "time" - "github.com/hashicorp/nomad/client/allocdir" "github.com/hashicorp/nomad/client/config" "github.com/hashicorp/nomad/client/driver/executor" cstructs "github.com/hashicorp/nomad/client/driver/structs" @@ -110,7 +109,7 @@ func (d *QemuDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, // Proceed to download an artifact to be executed. vmPath, err := getter.GetArtifact( - filepath.Join(taskDir, allocdir.TaskLocal), + taskDir, driverConfig.ArtifactSource, driverConfig.Checksum, d.logger, diff --git a/client/driver/raw_exec.go b/client/driver/raw_exec.go index 5c870e80f..08deca270 100644 --- a/client/driver/raw_exec.go +++ b/client/driver/raw_exec.go @@ -4,10 +4,8 @@ import ( "encoding/json" "fmt" "log" - "path/filepath" "time" - "github.com/hashicorp/nomad/client/allocdir" "github.com/hashicorp/nomad/client/config" "github.com/hashicorp/nomad/client/driver/executor" cstructs "github.com/hashicorp/nomad/client/driver/structs" @@ -80,7 +78,7 @@ func (d *RawExecDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandl if ok && source != "" { // Proceed to download an artifact to be executed. _, err := getter.GetArtifact( - filepath.Join(taskDir, allocdir.TaskLocal), + taskDir, driverConfig.ArtifactSource, driverConfig.Checksum, d.logger, diff --git a/client/driver/raw_exec_test.go b/client/driver/raw_exec_test.go index d0af75598..fffd55089 100644 --- a/client/driver/raw_exec_test.go +++ b/client/driver/raw_exec_test.go @@ -104,7 +104,7 @@ func TestRawExecDriver_Start_Artifact_basic(t *testing.T) { Name: "sleep", Config: map[string]interface{}{ "artifact_source": fmt.Sprintf("%s/%s", ts.URL, file), - "command": filepath.Join("$NOMAD_TASK_DIR", file), + "command": file, "args": []string{"sleep", "1s"}, }, Resources: basicResources, @@ -151,7 +151,7 @@ func TestRawExecDriver_Start_Artifact_expanded(t *testing.T) { Name: "sleep", Config: map[string]interface{}{ "artifact_source": fmt.Sprintf("%s/%s", ts.URL, file), - "command": filepath.Join("$NOMAD_TASK_DIR", file), + "command": file, "args": []string{"sleep", "1s"}, }, Resources: basicResources, diff --git a/website/source/docs/drivers/exec.html.md b/website/source/docs/drivers/exec.html.md index 116ceb661..a2b05f168 100644 --- a/website/source/docs/drivers/exec.html.md +++ b/website/source/docs/drivers/exec.html.md @@ -69,7 +69,7 @@ To execute a binary specified by `artifact_source`: config { artifact_source = "https://dl.dropboxusercontent.com/u/1234/binary.bin" checksum = "sha256:abd123445ds4555555555" - command = "$NOMAD_TASK_DIR/binary.bin" + command = "binary.bin" } ``` diff --git a/website/source/docs/drivers/raw_exec.html.md b/website/source/docs/drivers/raw_exec.html.md index 3f3dd75fa..90b3f24c7 100644 --- a/website/source/docs/drivers/raw_exec.html.md +++ b/website/source/docs/drivers/raw_exec.html.md @@ -75,7 +75,7 @@ To execute a binary specified by `artifact_source`: config { artifact_source = "https://dl.dropboxusercontent.com/u/1234/binary.bin" checksum = "sha256:133jifjiofu9090fsadjofsdjlk" - command = "$NOMAD_TASK_DIR/binary.bin" + command = "binary.bin" } ```