Skip to content

Commit

Permalink
Remove new execution requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessandroPatti committed Mar 13, 2024
1 parent 2e442bf commit 77a542a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,4 @@ public enum WorkerProtocolFormat {
* segment from the paths of all inputs and outputs.
*/
public static final String SUPPORTS_PATH_MAPPING = "supports-path-mapping";

/** Disables cgroups for a sandbox spawn */
public static final String NO_SUPPORTS_CGROUPS = "no-supports-cgroups";
}
Original file line number Diff line number Diff line change
Expand Up @@ -333,24 +333,22 @@ protected SandboxedSpawn prepareSpawn(Spawn spawn, SpawnExecutionContext context
commandLineBuilder.setSandboxDebugPath(sandboxDebugPath.getPathString());
}

if (!spawn.getExecutionInfo().containsKey(ExecutionRequirements.NO_SUPPORTS_CGROUPS)) {
if (cgroupFactory != null) {
ImmutableMap<String, Double> spawnResourceLimits = ImmutableMap.of();
if (sandboxOptions.enforceResources.regexPattern().matcher(spawn.getMnemonic()).matches()) {
spawnResourceLimits = spawn.getLocalResources().getResources();
}
VirtualCGroup cgroup = cgroupFactory.create(context.getId(), spawnResourceLimits);
commandLineBuilder.setCgroupsDirs(cgroup.paths());
} else if (sandboxOptions.memoryLimitMb > 0) {
// We put the sandbox inside a unique subdirectory using the context's ID. This ID is
// unique per spawn run by this spawn runner.
CgroupsInfo sandboxCgroup =
CgroupsInfo.getBlazeSpawnsCgroup()
.createIndividualSpawnCgroup(
"sandbox_" + context.getId(), sandboxOptions.memoryLimitMb);
if (sandboxCgroup.exists()) {
commandLineBuilder.setCgroupsDirs(ImmutableSet.of(sandboxCgroup.getCgroupDir().toPath()));
}
if (cgroupFactory != null) {
ImmutableMap<String, Double> spawnResourceLimits = ImmutableMap.of();
if (sandboxOptions.enforceResources.regexPattern().matcher(spawn.getMnemonic()).matches()) {
spawnResourceLimits = spawn.getLocalResources().getResources();
}
VirtualCGroup cgroup = cgroupFactory.create(context.getId(), spawnResourceLimits);
commandLineBuilder.setCgroupsDirs(cgroup.paths());
} else if (sandboxOptions.memoryLimitMb > 0) {
// We put the sandbox inside a unique subdirectory using the context's ID. This ID is
// unique per spawn run by this spawn runner.
CgroupsInfo sandboxCgroup =
CgroupsInfo.getBlazeSpawnsCgroup()
.createIndividualSpawnCgroup(
"sandbox_" + context.getId(), sandboxOptions.memoryLimitMb);
if (sandboxCgroup.exists()) {
commandLineBuilder.setCgroupsDirs(ImmutableSet.of(sandboxCgroup.getCgroupDir().toPath()));
}
}

Expand Down

0 comments on commit 77a542a

Please sign in to comment.