aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/sandbox
diff options
context:
space:
mode:
authorGravatar jmmv <jmmv@google.com>2018-03-23 02:47:44 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-23 02:49:10 -0700
commit7a51a7c44df334f8e67a793788caf520b5127db4 (patch)
tree7e50ac2fd8ba2a1a2830d32be9ec9e3c53fe26cb /src/main/java/com/google/devtools/build/lib/sandbox
parent3b9cf80c3cadce94ca4a7aa1a3f5c8756e4ac9e4 (diff)
Remove unnecessary product name and constructors from sandboxed spawn runners.
The product name was previously propagated to all sandboxed spawn runners unconditionally, even when the majority did not need it. Also, these same spawn runners had obsolete constructors that were not used at all or were only used in tests. Remove both for simplicity. RELNOTES: None. PiperOrigin-RevId: 190195305
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/sandbox')
-rw-r--r--src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java33
-rw-r--r--src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java30
-rw-r--r--src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java27
-rw-r--r--src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextProvider.java8
4 files changed, 3 insertions, 95 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java
index e80edf03f1..109f5e4443 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/DarwinSandboxedSpawnRunner.java
@@ -96,7 +96,6 @@ final class DarwinSandboxedSpawnRunner extends AbstractSandboxSpawnRunner {
private final Path execRoot;
private final boolean allowNetwork;
- private final String productName;
private final Path processWrapper;
private final Optional<Duration> timeoutKillDelay;
private final @Nullable SandboxfsProcess sandboxfsProcess;
@@ -111,40 +110,10 @@ final class DarwinSandboxedSpawnRunner extends AbstractSandboxSpawnRunner {
/**
* Creates a sandboxed spawn runner that uses the {@code process-wrapper} tool and the MacOS
- * {@code sandbox-exec} binary. If a spawn exceeds its timeout, then it will be killed instantly.
- *
- * @param cmdEnv the command environment to use
- * @param sandboxBase path to the sandbox base directory
- * @param productName the product name to use
- */
- DarwinSandboxedSpawnRunner(CommandEnvironment cmdEnv, Path sandboxBase, String productName)
- throws IOException {
- this(cmdEnv, sandboxBase, productName, Optional.empty(), null);
- }
-
- /**
- * Creates a sandboxed spawn runner that uses the {@code process-wrapper} tool and the MacOS
- * {@code sandbox-exec} binary. If a spawn exceeds its timeout, then it will be killed after the
- * specified delay.
- *
- * @param cmdEnv the command environment to use
- * @param sandboxBase path to the sandbox base directory
- * @param productName the product name to use
- * @param timeoutKillDelay an additional grace period before killing timing out commands
- */
- DarwinSandboxedSpawnRunner(
- CommandEnvironment cmdEnv, Path sandboxBase, String productName, Duration timeoutKillDelay)
- throws IOException {
- this(cmdEnv, sandboxBase, productName, Optional.of(timeoutKillDelay), null);
- }
-
- /**
- * Creates a sandboxed spawn runner that uses the {@code process-wrapper} tool and the MacOS
* {@code sandbox-exec} binary.
*
* @param cmdEnv the command environment to use
* @param sandboxBase path to the sandbox base directory
- * @param productName the product name to use
* @param timeoutKillDelay an optional, additional grace period before killing timing out
* commands. If not present, then no grace period is used and commands are killed instantly.
* @param sandboxfsProcess instance of the sandboxfs process to use; may be null for none, in
@@ -153,14 +122,12 @@ final class DarwinSandboxedSpawnRunner extends AbstractSandboxSpawnRunner {
DarwinSandboxedSpawnRunner(
CommandEnvironment cmdEnv,
Path sandboxBase,
- String productName,
Optional<Duration> timeoutKillDelay,
@Nullable SandboxfsProcess sandboxfsProcess)
throws IOException {
super(cmdEnv, sandboxBase);
this.execRoot = cmdEnv.getExecRoot();
this.allowNetwork = SandboxHelpers.shouldAllowNetwork(cmdEnv.getOptions());
- this.productName = productName;
this.alwaysWritableDirs = getAlwaysWritableDirs(cmdEnv.getRuntime().getFileSystem());
this.processWrapper = ProcessWrapperUtil.getProcessWrapper(cmdEnv);
this.localEnvProvider =
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 360fcbbce4..32997347b8 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
@@ -42,46 +42,16 @@ public final class LinuxSandboxedStrategy extends AbstractSpawnStrategy {
}
/**
- * Creates a sandboxed spawn runner that uses the {@code linux-sandbox} tool. If a spawn exceeds
- * its timeout, then it will be killed instantly.
- *
- * @param cmdEnv the command environment to use
- * @param sandboxBase path to the sandbox base directory
- * @param productName the product name to use
- */
- static LinuxSandboxedSpawnRunner create(
- CommandEnvironment cmdEnv, Path sandboxBase, String productName) throws IOException {
- return create(cmdEnv, sandboxBase, productName, Optional.empty());
- }
-
- /**
- * Creates a sandboxed spawn runner that uses the {@code linux-sandbox} tool. If a spawn exceeds
- * its timeout, then it will be killed after the specified delay.
- *
- * @param cmdEnv the command environment to use
- * @param sandboxBase path to the sandbox base directory
- * @param productName the product name to use
- * @param timeoutKillDelay an additional grace period before killing timing out commands
- */
- static LinuxSandboxedSpawnRunner create(
- CommandEnvironment cmdEnv, Path sandboxBase, String productName, Duration timeoutKillDelay)
- throws IOException {
- return create(cmdEnv, sandboxBase, productName, Optional.of(timeoutKillDelay));
- }
-
- /**
* Creates a sandboxed spawn runner that uses the {@code linux-sandbox} tool.
*
* @param cmdEnv the command environment to use
* @param sandboxBase path to the sandbox base directory
- * @param productName the product name to use
* @param timeoutKillDelay an optional, additional grace period before killing timing out
* commands. If not present, then no grace period is used and commands are killed instantly.
*/
static LinuxSandboxedSpawnRunner create(
CommandEnvironment cmdEnv,
Path sandboxBase,
- String productName,
Optional<Duration> timeoutKillDelay)
throws IOException {
Path inaccessibleHelperFile = sandboxBase.getRelative("inaccessibleHelperFile");
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java
index dca292efca..a61b6e150f 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/ProcessWrapperSandboxedSpawnRunner.java
@@ -42,33 +42,6 @@ final class ProcessWrapperSandboxedSpawnRunner extends AbstractSandboxSpawnRunne
private final Optional<Duration> timeoutKillDelay;
/**
- * Creates a sandboxed spawn runner that uses the {@code process-wrapper} tool. If a spawn exceeds
- * its timeout, then it will be killed instantly.
- *
- * @param cmdEnv the command environment to use
- * @param sandboxBase path to the sandbox base directory
- * @param productName the product name to use
- */
- ProcessWrapperSandboxedSpawnRunner(
- CommandEnvironment cmdEnv, Path sandboxBase, String productName) {
- this(cmdEnv, sandboxBase, productName, Optional.empty());
- }
-
- /**
- * Creates a sandboxed spawn runner that uses the {@code process-wrapper} tool. If a spawn exceeds
- * its timeout, then it will be killed after the specified delay.
- *
- * @param cmdEnv the command environment to use
- * @param sandboxBase path to the sandbox base directory
- * @param productName the product name to use
- * @param timeoutKillDelay an additional grace period before killing timing out commands
- */
- ProcessWrapperSandboxedSpawnRunner(
- CommandEnvironment cmdEnv, Path sandboxBase, String productName, Duration timeoutKillDelay) {
- this(cmdEnv, sandboxBase, productName, Optional.of(timeoutKillDelay));
- }
-
- /**
* Creates a sandboxed spawn runner that uses the {@code process-wrapper} tool.
*
* @param cmdEnv the command environment to use
diff --git a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextProvider.java b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextProvider.java
index 37b100cf6d..31da786227 100644
--- a/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/sandbox/SandboxActionContextProvider.java
@@ -59,7 +59,6 @@ final class SandboxActionContextProvider extends ActionContextProvider {
if (timeoutKillDelaySeconds >= 0) {
timeoutKillDelay = Optional.of(Duration.ofSeconds(timeoutKillDelaySeconds));
}
- String productName = cmdEnv.getRuntime().getProductName();
// This works on most platforms, but isn't the best choice, so we put it first and let later
// platform-specific sandboxing strategies become the default.
@@ -68,7 +67,7 @@ final class SandboxActionContextProvider extends ActionContextProvider {
withFallback(
cmdEnv,
new ProcessWrapperSandboxedSpawnRunner(
- cmdEnv, sandboxBase, productName, timeoutKillDelay));
+ cmdEnv, sandboxBase, cmdEnv.getRuntime().getProductName(), timeoutKillDelay));
contexts.add(new ProcessWrapperSandboxedStrategy(cmdEnv.getExecRoot(), spawnRunner));
}
@@ -78,7 +77,7 @@ final class SandboxActionContextProvider extends ActionContextProvider {
SpawnRunner spawnRunner =
withFallback(
cmdEnv,
- LinuxSandboxedStrategy.create(cmdEnv, sandboxBase, productName, timeoutKillDelay));
+ LinuxSandboxedStrategy.create(cmdEnv, sandboxBase, timeoutKillDelay));
contexts.add(new LinuxSandboxedStrategy(cmdEnv.getExecRoot(), spawnRunner));
}
@@ -87,8 +86,7 @@ final class SandboxActionContextProvider extends ActionContextProvider {
SpawnRunner spawnRunner =
withFallback(
cmdEnv,
- new DarwinSandboxedSpawnRunner(cmdEnv, sandboxBase, productName, timeoutKillDelay,
- process));
+ new DarwinSandboxedSpawnRunner(cmdEnv, sandboxBase, timeoutKillDelay, process));
contexts.add(new DarwinSandboxedStrategy(cmdEnv.getExecRoot(), spawnRunner));
}