diff options
author | Philipp Wollermann <philwo@google.com> | 2016-09-20 12:53:37 +0000 |
---|---|---|
committer | Laszlo Csomor <laszlocsomor@google.com> | 2016-09-21 07:04:12 +0000 |
commit | 52f4e8bbaf18ea489acd2db464f267757e8eb6d4 (patch) | |
tree | 608c16dd0160d6b355def1f71c0cee4239bed3f5 /src/main/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategy.java | |
parent | 08849b29198230eacd4e85fc7246be8e399e4c4d (diff) |
Fix Bazel failing to build anything when its workspace or output base is in /tmp.
Add "-b" option to linux-sandbox to explicitly bind mount files / directories into the sandbox. This is used to pull in the workspace and output base of Bazel even when they're located in /tmp and would thus be hidden by the tmpfs we mount on the /tmp directory in the sandbox.
Add "-S" option to linux-sandbox to explicitly specify a temporary directory to be used to contain the sandbox. This can be created by Bazel and then removed more reliably, compared to the earlier behavior where the sandbox would create its own temporary root directory in /tmp/sandbox.XXXXXX (and fail to delete it in case it gets killed by a signal).
Fix spurious empty.XXXXXX files and directories not being deleted from /tmp.
--
MOS_MIGRATED_REVID=133695992
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.java | 17 |
1 files changed, 17 insertions, 0 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 be49446a82..0e38d0d891 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 @@ -101,6 +101,7 @@ public class LinuxSandboxedStrategy extends SandboxStrategy { // Each invocation of "exec" gets its own sandbox. Path sandboxPath = SandboxHelpers.getSandboxRoot(blazeDirs, productName, uuid, execCounter); Path sandboxExecRoot = sandboxPath.getRelative("execroot").getRelative(execRoot.getBaseName()); + Path sandboxTempDir = sandboxPath.getRelative("tmp"); try { @@ -110,6 +111,7 @@ public class LinuxSandboxedStrategy extends SandboxStrategy { Set<Path> writableDirs = getWritableDirs(sandboxExecRoot, spawn.getEnvironment(), outputs); symlinkedExecRoot.createFileSystem( getMounts(spawn, actionExecutionContext), outputs, writableDirs); + sandboxTempDir.createDirectory(); final SandboxRunner runner; if (fullySupported) { @@ -118,8 +120,10 @@ public class LinuxSandboxedStrategy extends SandboxStrategy { execRoot, sandboxPath, sandboxExecRoot, + sandboxTempDir, getWritableDirs(sandboxExecRoot, spawn.getEnvironment(), outputs), getInaccessiblePaths(), + getBindMounts(blazeDirs), verboseFailures, sandboxOptions.sandboxDebug); } else { @@ -143,4 +147,17 @@ public class LinuxSandboxedStrategy extends SandboxStrategy { } } + private ImmutableSet<Path> getBindMounts(BlazeDirectories blazeDirs) { + Path tmpPath = blazeDirs.getFileSystem().getPath("/tmp"); + ImmutableSet.Builder<Path> bindMounts = ImmutableSet.builder(); + if (blazeDirs.getWorkspace().startsWith(tmpPath)) { + + bindMounts.add(blazeDirs.getWorkspace()); + } + if (blazeDirs.getOutputBase().startsWith(tmpPath)) { + bindMounts.add(blazeDirs.getOutputBase()); + } + return bindMounts.build(); + } + } |