Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly break down sandboxed spawns. #10434

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ public final SpawnResult exec(Spawn spawn, SpawnExecutionContext context)
try (ResourceHandle ignored =
resourceManager.acquireResources(owner, spawn.getLocalResources())) {
context.report(ProgressStatus.EXECUTING, getName());
SandboxedSpawn sandbox;
try (SilentCloseable c = Profiler.instance().profile("SandboxedSpawn.prepareSpawn")) {
sandbox = prepareSpawn(spawn, context);
}
SandboxedSpawn sandbox = prepareSpawn(spawn, context);
return runSpawn(spawn, sandbox, context);
} catch (IOException e) {
throw new UserExecException("I/O exception during sandboxed execution", e);
Expand All @@ -102,14 +99,21 @@ private SpawnResult runSpawn(
Spawn originalSpawn, SandboxedSpawn sandbox, SpawnExecutionContext context)
throws IOException, InterruptedException {
try {
sandbox.createFileSystem();
try (SilentCloseable c = Profiler.instance().profile("sandbox.createFileSystem")) {
sandbox.createFileSystem();
}
FileOutErr outErr = context.getFileOutErr();
context.prefetchInputs();
try (SilentCloseable c = Profiler.instance().profile("context.prefetchInputs")) {
context.prefetchInputs();
}

SpawnResult result = run(originalSpawn, sandbox, context.getTimeout(), outErr);
SpawnResult result;
try (SilentCloseable c = Profiler.instance().profile("subprocess.run")) {
result = run(originalSpawn, sandbox, context.getTimeout(), outErr);
}

context.lockOutputFiles();
try {
try (SilentCloseable c = Profiler.instance().profile("sandbox.copyOutputs")) {
// We copy the outputs even when the command failed.
sandbox.copyOutputs(execRoot);
} catch (IOException e) {
Expand All @@ -118,7 +122,9 @@ private SpawnResult runSpawn(
return result;
} finally {
if (!sandboxOptions.sandboxDebug) {
sandbox.delete();
try (SilentCloseable c = Profiler.instance().profile("sandbox.delete")) {
sandbox.delete();
}
}
}
}
Expand Down