aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java
diff options
context:
space:
mode:
authorGravatar Yue Gan <yueg@google.com>2016-08-29 11:21:52 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-08-29 13:00:21 +0000
commitd0d6cf7f2a88624e443a7f5e50e21e6653f73d3e (patch)
tree4cc41b7ea41233b96a311d1135ed6b4725140272 /src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java
parent080dfc1ecb6fa3f7dd0f4e96e96b45a548724e4b (diff)
Add LinuxAlmostSandboxRunner which uses process-wrapper instead of linux-sandbox in the same sandbox execution environment.
-- Change-Id: I51a875a87d92ae13ad575eb41026ce5d3db94f8b Reviewed-on: https://bazel-review.googlesource.com/#/c/5611/ MOS_MIGRATED_REVID=131578077
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java
index d6e65c34d7..962d24a349 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java
@@ -63,7 +63,9 @@ public class LinuxSandboxedStrategy implements SpawnActionContext {
public static boolean isSupported(CommandEnvironment env) {
if (sandboxingSupported == null) {
- sandboxingSupported = LinuxSandboxRunner.isSupported(env);
+ // Currently LinuxSandboxRunner support <= LinuxAlmostSandboxRunner support
+ sandboxingSupported =
+ LinuxAlmostSandboxRunner.isSupported(env) || LinuxSandboxRunner.isSupported(env);
}
return sandboxingSupported.booleanValue();
}
@@ -78,13 +80,15 @@ public class LinuxSandboxedStrategy implements SpawnActionContext {
private final UUID uuid = UUID.randomUUID();
private final AtomicInteger execCounter = new AtomicInteger();
private final String productName;
+ private final boolean fullySupported;
LinuxSandboxedStrategy(
BuildRequest buildRequest,
BlazeDirectories blazeDirs,
ExecutorService backgroundWorkers,
boolean verboseFailures,
- String productName) {
+ String productName,
+ boolean fullySupported) {
this.buildRequest = buildRequest;
this.sandboxOptions = buildRequest.getOptions(SandboxOptions.class);
this.blazeDirs = blazeDirs;
@@ -92,6 +96,7 @@ public class LinuxSandboxedStrategy implements SpawnActionContext {
this.backgroundWorkers = Preconditions.checkNotNull(backgroundWorkers);
this.verboseFailures = verboseFailures;
this.productName = productName;
+ this.fullySupported = fullySupported;
}
/**
@@ -154,14 +159,27 @@ public class LinuxSandboxedStrategy implements SpawnActionContext {
}
try {
- final LinuxSandboxRunner runner =
- new LinuxSandboxRunner(
- execRoot,
- sandboxExecRoot,
- writablePaths,
- inaccessiblePaths,
- verboseFailures,
- sandboxOptions.sandboxDebug);
+ final LinuxSandboxRunner runner;
+ if (fullySupported) {
+ runner =
+ new LinuxSandboxRunner(
+ execRoot,
+ sandboxExecRoot,
+ writablePaths,
+ inaccessiblePaths,
+ verboseFailures,
+ sandboxOptions.sandboxDebug);
+ } else {
+ // Then LinuxAlmostSandboxRunner must be supported
+ runner =
+ new LinuxAlmostSandboxRunner(
+ execRoot,
+ sandboxExecRoot,
+ writablePaths,
+ inaccessiblePaths,
+ verboseFailures,
+ sandboxOptions.sandboxDebug);
+ }
try {
runner.run(
spawn.getArguments(),