use of build.bazel.remote.execution.v2.OutputFile in project bazel-buildfarm by bazelbuild.
the class ShardWorkerContext method uploadOutputFile.
private void uploadOutputFile(ActionResult.Builder resultBuilder, String outputFile, Path actionRoot, PreconditionFailure.Builder preconditionFailure) throws IOException, InterruptedException {
Path outputPath = actionRoot.resolve(outputFile);
if (!Files.exists(outputPath)) {
logger.log(Level.FINE, "ReportResultStage: " + outputFile + " does not exist...");
return;
}
if (Files.isDirectory(outputPath)) {
logger.log(Level.FINE, "ReportResultStage: " + outputFile + " is a directory");
preconditionFailure.addViolationsBuilder().setType(VIOLATION_TYPE_INVALID).setSubject(outputFile).setDescription("An output file was a directory");
return;
}
long size = Files.size(outputPath);
long maxEntrySize = execFileSystem.getStorage().maxEntrySize();
if (maxEntrySize != UNLIMITED_ENTRY_SIZE_MAX && size > maxEntrySize) {
preconditionFailure.addViolationsBuilder().setType(VIOLATION_TYPE_MISSING).setSubject(outputFile + ": " + size).setDescription("An output could not be uploaded because it exceeded the maximum size of an entry");
return;
}
// will run into issues if we end up blocking on the cache insertion, might
// want to decrement input references *before* this to ensure that we cannot
// cause an internal deadlock
Digest digest;
try {
digest = getDigestUtil().compute(outputPath);
} catch (NoSuchFileException e) {
return;
}
resultBuilder.addOutputFilesBuilder().setPath(outputFile).setDigest(digest).setIsExecutable(Files.isExecutable(outputPath));
try {
insertFile(digest, outputPath);
} catch (EntryLimitException e) {
preconditionFailure.addViolationsBuilder().setType(VIOLATION_TYPE_MISSING).setSubject("blobs/" + DigestUtil.toString(digest)).setDescription("An output could not be uploaded because it exceeded the maximum size of an entry");
}
}
use of build.bazel.remote.execution.v2.OutputFile in project bazel-buildfarm by bazelbuild.
the class AbstractServerInstance method findMissingActionResultOutputs.
protected ListenableFuture<Iterable<Digest>> findMissingActionResultOutputs(@Nullable ActionResult result, Executor executor, RequestMetadata requestMetadata) {
if (result == null) {
return immediateFuture(ImmutableList.of());
}
ImmutableList.Builder<Digest> digests = ImmutableList.builder();
digests.addAll(Iterables.transform(result.getOutputFilesList(), OutputFile::getDigest));
// findMissingBlobs will weed out empties
digests.add(result.getStdoutDigest());
digests.add(result.getStderrDigest());
ListenableFuture<Void> digestsCompleteFuture = immediateFuture(null);
Executor contextExecutor = Context.current().fixedContextExecutor(executor);
for (OutputDirectory directory : result.getOutputDirectoriesList()) {
// TODO make tree cache
// create an async function here to avoid initiating the calls to expect immediately
// no synchronization required on digests, since only one request is running at a time
AsyncFunction<Void, Void> next = v -> transform(expect(directory.getTreeDigest(), build.bazel.remote.execution.v2.Tree.parser(), executor, requestMetadata), tree -> {
digests.addAll(enumerateTreeFileDigests(tree));
return null;
}, executor);
digestsCompleteFuture = transformAsync(digestsCompleteFuture, next, contextExecutor);
}
return transformAsync(digestsCompleteFuture, v -> findMissingBlobs(digests.build(), requestMetadata), contextExecutor);
}
use of build.bazel.remote.execution.v2.OutputFile in project bazel-buildfarm by bazelbuild.
the class Cat method printCommand.
private static void printCommand(int level, Command command) {
for (String outputFile : command.getOutputFilesList()) {
indentOut(level, "OutputFile: " + outputFile);
}
for (String outputDirectory : command.getOutputDirectoriesList()) {
indentOut(level, "OutputDirectory: " + outputDirectory);
}
// FIXME platform
indentOut(level, "Arguments: ('" + String.join("', '", command.getArgumentsList()) + "')");
if (!command.getEnvironmentVariablesList().isEmpty()) {
indentOut(level, "Environment Variables:");
for (EnvironmentVariable env : command.getEnvironmentVariablesList()) {
indentOut(level, " " + env.getName() + "='" + env.getValue() + "'");
}
}
indentOut(level, "Platform: " + command.getPlatform());
indentOut(level, "WorkingDirectory: " + command.getWorkingDirectory());
}
use of build.bazel.remote.execution.v2.OutputFile in project bazel-buildfarm by bazelbuild.
the class Cat method printActionResult.
@SuppressWarnings("ConstantConditions")
private static void printActionResult(ActionResult result, int indentLevel) {
for (OutputFile outputFile : result.getOutputFilesList()) {
String attrs = "";
if (outputFile.getIsExecutable()) {
attrs += (attrs.length() == 0 ? "" : ",") + "executable";
}
if (attrs.length() != 0) {
attrs = " (" + attrs + ")";
}
indentOut(indentLevel, "Output File: " + outputFile.getPath() + attrs + " File " + DigestUtil.toString(outputFile.getDigest()));
}
for (OutputDirectory outputDirectory : result.getOutputDirectoriesList()) {
indentOut(indentLevel, "Output Directory: " + outputDirectory.getPath() + " Directory " + DigestUtil.toString(outputDirectory.getTreeDigest()));
}
indentOut(indentLevel, "Exit Code: " + result.getExitCode());
if (!result.getStdoutRaw().isEmpty()) {
indentOut(indentLevel, "Stdout: " + result.getStdoutRaw().toStringUtf8());
}
if (result.hasStdoutDigest()) {
indentOut(indentLevel, "Stdout Digest: " + DigestUtil.toString(result.getStdoutDigest()));
}
if (!result.getStderrRaw().isEmpty()) {
indentOut(indentLevel, "Stderr: " + result.getStderrRaw().toStringUtf8());
}
if (result.hasStderrDigest()) {
indentOut(indentLevel, "Stderr Digest: " + DigestUtil.toString(result.getStderrDigest()));
}
if (result.hasExecutionMetadata()) {
indentOut(indentLevel, "ExecutionMetadata:");
ExecutedActionMetadata executedActionMetadata = result.getExecutionMetadata();
indentOut(indentLevel + 1, "Worker: " + executedActionMetadata.getWorker());
indentOut(indentLevel + 1, "Queued At: " + Timestamps.toString(executedActionMetadata.getQueuedTimestamp()));
indentOut(indentLevel + 1, "Worker Start: " + Timestamps.toString(executedActionMetadata.getWorkerStartTimestamp()));
indentOut(indentLevel + 1, "Input Fetch Start: " + Timestamps.toString(executedActionMetadata.getInputFetchStartTimestamp()));
indentOut(indentLevel + 1, "Input Fetch Completed: " + Timestamps.toString(executedActionMetadata.getInputFetchCompletedTimestamp()));
indentOut(indentLevel + 1, "Execution Start: " + Timestamps.toString(executedActionMetadata.getExecutionStartTimestamp()));
indentOut(indentLevel + 1, "Execution Completed: " + Timestamps.toString(executedActionMetadata.getExecutionCompletedTimestamp()));
indentOut(indentLevel + 1, "Output Upload Start: " + Timestamps.toString(executedActionMetadata.getOutputUploadStartTimestamp()));
indentOut(indentLevel + 1, "Output Upload Completed: " + Timestamps.toString(executedActionMetadata.getOutputUploadCompletedTimestamp()));
indentOut(indentLevel + 1, "Worker Completed: " + Timestamps.toString(executedActionMetadata.getWorkerCompletedTimestamp()));
}
}
Aggregations