Skip to content

Commit

Permalink
sandbox: Remove debug logging in DarwinSandboxedStrategy.
Browse files Browse the repository at this point in the history
Change-Id: Idc023f3a8c1c3b60d3f3f23a579a5eccb92d074d
PiperOrigin-RevId: 155487527
  • Loading branch information
philwo authored and kchodorow committed May 9, 2017
1 parent 92bad29 commit 72a377b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.Symlinks;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -179,41 +176,22 @@ protected void actuallyExec(
.post(ActionStatusMessage.runningStrategy(spawn.getResourceOwner(), "darwin-sandbox"));
SandboxHelpers.reportSubcommand(executor, spawn);

PrintWriter errWriter = null;
if (sandboxDebug) {
errWriter =
new PrintWriter(
new BufferedWriter(
new OutputStreamWriter(
actionExecutionContext.getFileOutErr().getErrorStream(), UTF_8)));
}

// Each invocation of "exec" gets its own sandbox.
Path sandboxPath = getSandboxRoot();
Path sandboxExecRoot = sandboxPath.getRelative("execroot").getRelative(execRoot.getBaseName());

if (errWriter != null) {
errWriter.printf("sandbox root is %s\n", sandboxPath.toString());
errWriter.printf("working dir is %s\n", sandboxExecRoot.toString());
}

ImmutableMap<String, String> spawnEnvironment =
StandaloneSpawnStrategy.locallyDeterminedEnv(execRoot, productName, spawn.getEnvironment());

HashSet<Path> writableDirs = new HashSet<>(alwaysWritableDirs);
writableDirs.addAll(getWritableDirs(sandboxExecRoot, spawnEnvironment));

HardlinkedExecRoot hardlinkedExecRoot =
new HardlinkedExecRoot(execRoot, sandboxPath, sandboxExecRoot, errWriter);
new HardlinkedExecRoot(execRoot, sandboxPath, sandboxExecRoot);
ImmutableSet<PathFragment> outputs = SandboxHelpers.getOutputFiles(spawn);
hardlinkedExecRoot.createFileSystem(
getMounts(spawn, actionExecutionContext), outputs, writableDirs);

// Flush our logs before executing the spawn, otherwise they might get overwritten.
if (errWriter != null) {
errWriter.flush();
}

DarwinSandboxRunner runner =
new DarwinSandboxRunner(sandboxPath, sandboxExecRoot, writableDirs, verboseFailures);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
Expand All @@ -35,14 +34,11 @@ public class HardlinkedExecRoot implements SandboxExecRoot {
private final Path execRoot;
private final Path sandboxPath;
private final Path sandboxExecRoot;
private final PrintWriter errWriter;

public HardlinkedExecRoot(
Path execRoot, Path sandboxPath, Path sandboxExecRoot, PrintWriter errWriter) {
public HardlinkedExecRoot(Path execRoot, Path sandboxPath, Path sandboxExecRoot) {
this.execRoot = execRoot;
this.sandboxPath = sandboxPath;
this.sandboxExecRoot = sandboxExecRoot;
this.errWriter = errWriter;
}

@Override
Expand All @@ -55,9 +51,6 @@ public void createFileSystem(

// Create all needed directories.
for (Path createDir : writableDirs) {
if (errWriter != null) {
errWriter.printf("createdir: %s\n", createDir.getPathString());
}
FileSystemUtils.createDirectoryAndParentsWithCache(createdDirs, createDir);
}

Expand Down Expand Up @@ -114,9 +107,6 @@ private void linkInputs(Map<PathFragment, Path> inputs, Set<Path> createdDirs)
target.startsWith(execRoot)
? inputsDir.getRelative(target.relativeTo(execRoot))
: inputsDir.getRelative(entry.getKey());
if (errWriter != null) {
errWriter.printf("hardlink: %s -> %s\n", hardlinkName, target);
}
try {
createHardLink(hardlinkName, target);
} catch (IOException e) {
Expand All @@ -126,9 +116,6 @@ private void linkInputs(Map<PathFragment, Path> inputs, Set<Path> createdDirs)
}

// symlink
if (errWriter != null) {
errWriter.printf("symlink: %s -> %s\n", targetName, hardlinkName);
}
targetName.createSymbolicLink(hardlinkName);
}
}
Expand Down

0 comments on commit 72a377b

Please sign in to comment.