Extract artifacts to the root of the task, not in the local directory

This commit is contained in:
Alex Dadgar
2016-02-04 15:18:22 -08:00
parent c87a4f9f71
commit ca69bcd18b
8 changed files with 10 additions and 18 deletions

View File

@@ -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,

View File

@@ -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,
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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"
}
```

View File

@@ -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"
}
```