mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
exec2: more tweaks to driver harness (#20221)
Also add an explicit exit code to subproc package for when a child process is instructed to run an unrunnable command (i.e. cannot be found or is not executable) - with the 127 return code folks using bash are familiar with
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user