diff --git a/helper/subproc/subproc.go b/helper/subproc/subproc.go index 0cc18422d1cf..1857fa4f8711 100644 --- a/helper/subproc/subproc.go +++ b/helper/subproc/subproc.go @@ -15,13 +15,16 @@ import ( const ( // ExitSuccess indicates the subprocess completed successfully. - ExitSuccess = iota + ExitSuccess = 0 // ExitFailure indicates the subprocess terminated unsuccessfully. - ExitFailure + ExitFailure = 1 // ExitTimeout indicates the subprocess timed out before completion. - ExitTimeout + ExitTimeout = 2 + + // ExitNotRunnable indicates a command cannot be run. + ExitNotRunnable = 127 // bash-ism ) // MainFunc is the function that runs for this sub-process. diff --git a/plugins/drivers/testutils/testing.go b/plugins/drivers/testutils/testing.go index 2ebeb3b595a2..bf645f08f899 100644 --- a/plugins/drivers/testutils/testing.go +++ b/plugins/drivers/testutils/testing.go @@ -83,7 +83,11 @@ func (h *DriverHarness) MkAllocDir(t *drivers.TaskConfig, enableLogs bool) func( dir, err := os.MkdirTemp("", "nomad_driver_harness-") must.NoError(h.t, err) - allocDir := allocdir.NewAllocDir(h.logger, dir, dir, t.AllocID) + mountsDir, err := os.MkdirTemp("", "nomad_driver_harness-mounts-") + must.NoError(h.t, err) + must.NoError(h.t, os.Chmod(mountsDir, 0755)) + + allocDir := allocdir.NewAllocDir(h.logger, dir, mountsDir, t.AllocID) must.NoError(h.t, allocDir.Build()) t.AllocDir = allocDir.AllocDir @@ -261,7 +265,12 @@ func SetEnvvars(envBuilder *taskenv.Builder, fsmode fsisolation.Mode, taskDir *a // Set driver-specific environment variables switch fsmode { - case fsisolation.None, fsisolation.Unveil: + case fsisolation.Unveil: + // Use mounts host paths + envBuilder.SetAllocDir(filepath.Join(taskDir.MountsAllocDir, "alloc")) + envBuilder.SetTaskLocalDir(filepath.Join(taskDir.MountsTaskDir, "local")) + envBuilder.SetSecretsDir(filepath.Join(taskDir.SecretsDir, "secrets")) + case fsisolation.None: // Use host paths envBuilder.SetAllocDir(taskDir.SharedAllocDir) envBuilder.SetTaskLocalDir(taskDir.LocalDir)