Skip to content

Commit

Permalink
drivers/testutil: set full filepath for envs when using unveil fs iso…
Browse files Browse the repository at this point in the history
…lation (#20187)
  • Loading branch information
shoenig authored Mar 22, 2024
1 parent 23e4b7c commit c36db1b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions plugins/drivers/testutils/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/plugins/base"
"github.com/hashicorp/nomad/plugins/drivers"
"github.com/hashicorp/nomad/plugins/drivers/fsisolation"
"github.com/hashicorp/nomad/plugins/shared/hclspec"
testing "github.com/mitchellh/go-testing-interface"
"github.com/shoenig/test/must"
Expand Down Expand Up @@ -251,16 +252,16 @@ func (d *MockDriver) ExecTaskStreaming(ctx context.Context, taskID string, execO
}

// SetEnvvars sets path and host env vars depending on the FS isolation used.
func SetEnvvars(envBuilder *taskenv.Builder, fsi drivers.FSIsolation, taskDir *allocdir.TaskDir) {
func SetEnvvars(envBuilder *taskenv.Builder, fsmode fsisolation.Mode, taskDir *allocdir.TaskDir) {

envBuilder.SetClientTaskRoot(taskDir.Dir)
envBuilder.SetClientSharedAllocDir(taskDir.SharedAllocDir)
envBuilder.SetClientTaskLocalDir(taskDir.LocalDir)
envBuilder.SetClientTaskSecretsDir(taskDir.SecretsDir)

// Set driver-specific environment variables
switch fsi {
case drivers.FSIsolationNone:
switch fsmode {
case fsisolation.None, fsisolation.Unveil:
// Use host paths
envBuilder.SetAllocDir(taskDir.SharedAllocDir)
envBuilder.SetTaskLocalDir(taskDir.LocalDir)
Expand All @@ -273,7 +274,7 @@ func SetEnvvars(envBuilder *taskenv.Builder, fsi drivers.FSIsolation, taskDir *a
}

// Set the host environment variables for non-image based drivers
if fsi != drivers.FSIsolationImage {
if fsmode != fsisolation.Image {
envBuilder.SetHostEnvvars([]string{"env.denylist"})
}
}

0 comments on commit c36db1b

Please sign in to comment.