-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drivers/exec+java: Add task configuration to restore previous PID/IPC…
… isolation behavior This PR adds pid_mode and ipc_mode options to the exec and java task driver config options. By default these will defer to the default_pid_mode and default_ipc_mode agent plugin options created in #9969. Setting these values to "host" mode disables isolation for the task. Doing so is not recommended, but may be necessary to support legacy job configurations. Closes #9970
- Loading branch information
Showing
16 changed files
with
330 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package executor | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestUtils_IsolationMode(t *testing.T) { | ||
private := IsolationModePrivate | ||
host := IsolationModeHost | ||
blank := "" | ||
|
||
for _, tc := range []struct { | ||
plugin, task, exp string | ||
}{ | ||
{plugin: private, task: private, exp: private}, | ||
{plugin: private, task: host, exp: host}, | ||
{plugin: private, task: blank, exp: private}, // default to private | ||
|
||
{plugin: host, task: private, exp: private}, | ||
{plugin: host, task: host, exp: host}, | ||
{plugin: host, task: blank, exp: host}, // default to host | ||
} { | ||
result := IsolationMode(tc.plugin, tc.task) | ||
require.Equal(t, tc.exp, result) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
job "exec" { | ||
datacenters = ["dc1"] | ||
type = "batch" | ||
|
||
constraint { | ||
attribute = "${attr.kernel.name}" | ||
value = "linux" | ||
} | ||
|
||
group "exec" { | ||
task "exec" { | ||
driver = "exec" | ||
|
||
config { | ||
command = "bash" | ||
args = [ | ||
"-c", "local/pid.sh" | ||
] | ||
pid_mode = "host" | ||
ipc_mode = "host" | ||
} | ||
|
||
template { | ||
data = <<EOF | ||
#!/usr/bin/env bash | ||
echo my pid is $BASHPID | ||
EOF | ||
|
||
destination = "local/pid.sh" | ||
perms = "777" | ||
change_mode = "noop" | ||
} | ||
|
||
resources { | ||
cpu = 100 | ||
memory = 64 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
job "java_pid" { | ||
datacenters = ["dc1"] | ||
type = "batch" | ||
|
||
group "java" { | ||
|
||
task "build" { | ||
lifecycle { | ||
hook = "prestart" | ||
sidecar = false | ||
} | ||
|
||
driver = "exec" | ||
config { | ||
command = "javac" | ||
args = ["-d", "${NOMAD_ALLOC_DIR}", "local/Pid.java"] | ||
} | ||
|
||
template { | ||
destination = "local/Pid.java" | ||
data = <<EOH | ||
public class Pid { | ||
public static void main(String... s) throws Exception { | ||
System.out.println("my pid is " + ProcessHandle.current().pid()); | ||
} | ||
} | ||
EOH | ||
} | ||
} | ||
|
||
task "pid" { | ||
driver = "java" | ||
config { | ||
class_path = "${NOMAD_ALLOC_DIR}" | ||
class = "Pid" | ||
pid_mode = "host" | ||
ipc_mode = "host" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.