Search in sources :

Example 1 with OutputFile

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");
    }
}
Also used : Path(java.nio.file.Path) Digest(build.bazel.remote.execution.v2.Digest) NoSuchFileException(java.nio.file.NoSuchFileException) EntryLimitException(build.buildfarm.common.EntryLimitException)

Example 2 with OutputFile

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);
}
Also used : HttpURLConnection(java.net.HttpURLConnection) ExecuteOperationMetadata(build.bazel.remote.execution.v2.ExecuteOperationMetadata) ExecutingOperationMetadata(build.buildfarm.v1test.ExecutingOperationMetadata) DirectoryNode(build.bazel.remote.execution.v2.DirectoryNode) ExecutionStage(build.bazel.remote.execution.v2.ExecutionStage) Blob(build.buildfarm.cas.ContentAddressableStorage.Blob) StatusProto(io.grpc.protobuf.StatusProto) Tree(build.buildfarm.v1test.Tree) Map(java.util.Map) ServerCapabilities(build.bazel.remote.execution.v2.ServerCapabilities) Status(io.grpc.Status) ServerCallStreamObserver(io.grpc.stub.ServerCallStreamObserver) CacheCapabilities(build.bazel.remote.execution.v2.CacheCapabilities) OutputDirectory(build.bazel.remote.execution.v2.OutputDirectory) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ActionCache(build.buildfarm.ac.ActionCache) EntryLimitException(build.buildfarm.common.EntryLimitException) Set(java.util.Set) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) VIOLATION_TYPE_MISSING(build.buildfarm.common.Errors.VIOLATION_TYPE_MISSING) DirectoryEntry(build.buildfarm.common.TreeIterator.DirectoryEntry) ByteStreams(com.google.common.io.ByteStreams) Any(com.google.protobuf.Any) Actions.checkPreconditionFailure(build.buildfarm.common.Actions.checkPreconditionFailure) Directory(build.bazel.remote.execution.v2.Directory) Iterables(com.google.common.collect.Iterables) Command(build.bazel.remote.execution.v2.Command) MoreExecutors.newDirectExecutorService(com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService) QueuedOperation(build.buildfarm.v1test.QueuedOperation) ResultsCachePolicy(build.bazel.remote.execution.v2.ResultsCachePolicy) DigestUtil(build.buildfarm.common.DigestUtil) Action(build.bazel.remote.execution.v2.Action) Actions.asExecutionStatus(build.buildfarm.common.Actions.asExecutionStatus) Watcher(build.buildfarm.common.Watcher) VIOLATION_TYPE_INVALID(build.buildfarm.common.Errors.VIOLATION_TYPE_INVALID) FileNode(build.bazel.remote.execution.v2.FileNode) StreamSupport(java.util.stream.StreamSupport) WorkerListMessage(build.buildfarm.v1test.WorkerListMessage) Nullable(javax.annotation.Nullable) Futures.immediateFuture(com.google.common.util.concurrent.Futures.immediateFuture) Executor(java.util.concurrent.Executor) PreconditionFailure(com.google.rpc.PreconditionFailure) IOException(java.io.IOException) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) Futures(com.google.common.util.concurrent.Futures) WorkerProfileMessage(build.buildfarm.v1test.WorkerProfileMessage) Utils.putBlob(build.buildfarm.instance.Utils.putBlob) ExecuteResponse(build.bazel.remote.execution.v2.ExecuteResponse) QueryStringDecoder(io.netty.handler.codec.http.QueryStringDecoder) Preconditions(com.google.common.base.Preconditions) Trees.enumerateTreeFileDigests(build.buildfarm.common.Trees.enumerateTreeFileDigests) Futures.transform(com.google.common.util.concurrent.Futures.transform) NoSuchFileException(java.nio.file.NoSuchFileException) Context(io.grpc.Context) Futures.transformAsync(com.google.common.util.concurrent.Futures.transformAsync) URL(java.net.URL) SymlinkAbsolutePathStrategy(build.bazel.remote.execution.v2.SymlinkAbsolutePathStrategy) URISyntaxException(java.net.URISyntaxException) RequestMetadata(build.bazel.remote.execution.v2.RequestMetadata) ContentAddressableStorage(build.buildfarm.cas.ContentAddressableStorage) ActionKey(build.buildfarm.common.DigestUtil.ActionKey) SettableFuture(com.google.common.util.concurrent.SettableFuture) TokenizableIterator(build.buildfarm.common.TokenizableIterator) Digest(build.bazel.remote.execution.v2.Digest) CasIndexResults(build.buildfarm.common.CasIndexResults) URI(java.net.URI) ImmutableSet(com.google.common.collect.ImmutableSet) ExecutionCapabilities(build.bazel.remote.execution.v2.ExecutionCapabilities) ActionCacheUpdateCapabilities(build.bazel.remote.execution.v2.ActionCacheUpdateCapabilities) OutputFile(build.bazel.remote.execution.v2.OutputFile) UUID(java.util.UUID) Logger(java.util.logging.Logger) Platform(build.bazel.remote.execution.v2.Platform) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Instance(build.buildfarm.instance.Instance) Sets(com.google.common.collect.Sets) Parser(com.google.protobuf.Parser) ByteString(com.google.protobuf.ByteString) QueuedOperationMetadata(build.buildfarm.v1test.QueuedOperationMetadata) SymlinkNode(build.bazel.remote.execution.v2.SymlinkNode) Size(build.buildfarm.common.Size) MoreExecutors.listeningDecorator(com.google.common.util.concurrent.MoreExecutors.listeningDecorator) GetClientStartTimeRequest(build.buildfarm.v1test.GetClientStartTimeRequest) EnrichedOperation(build.buildfarm.operations.EnrichedOperation) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) StatusException(io.grpc.StatusException) Operation(com.google.longrunning.Operation) Stack(java.util.Stack) Level(java.util.logging.Level) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) GetClientStartTimeResult(build.buildfarm.v1test.GetClientStartTimeResult) DAYS(java.util.concurrent.TimeUnit.DAYS) FindOperationsResults(build.buildfarm.operations.FindOperationsResults) ActionResult(build.bazel.remote.execution.v2.ActionResult) Code(com.google.rpc.Code) ExecutorService(java.util.concurrent.ExecutorService) OutputStream(java.io.OutputStream) Violation(com.google.rpc.PreconditionFailure.Violation) Response(build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response) PrepareWorkerForGracefulShutDownRequestResults(build.buildfarm.v1test.PrepareWorkerForGracefulShutDownRequestResults) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) ExecutionPolicy(build.bazel.remote.execution.v2.ExecutionPolicy) BatchUpdateBlobsResponse(build.bazel.remote.execution.v2.BatchUpdateBlobsResponse) Write(build.buildfarm.common.Write) Futures.catchingAsync(com.google.common.util.concurrent.Futures.catchingAsync) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) DigestMismatchException(build.buildfarm.cas.DigestMismatchException) Futures.immediateFailedFuture(com.google.common.util.concurrent.Futures.immediateFailedFuture) AsyncFunction(com.google.common.util.concurrent.AsyncFunction) VisibleForTesting(com.google.common.annotations.VisibleForTesting) SECONDS(java.util.concurrent.TimeUnit.SECONDS) CompletedOperationMetadata(build.buildfarm.v1test.CompletedOperationMetadata) InputStream(java.io.InputStream) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) Executor(java.util.concurrent.Executor) Digest(build.bazel.remote.execution.v2.Digest) OutputDirectory(build.bazel.remote.execution.v2.OutputDirectory) ImmutableList(com.google.common.collect.ImmutableList)

Example 3 with OutputFile

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());
}
Also used : EnvironmentVariable(build.bazel.remote.execution.v2.Command.EnvironmentVariable) ByteString(com.google.protobuf.ByteString)

Example 4 with OutputFile

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()));
    }
}
Also used : OutputFile(build.bazel.remote.execution.v2.OutputFile) OutputDirectory(build.bazel.remote.execution.v2.OutputDirectory) ExecutedActionMetadata(build.bazel.remote.execution.v2.ExecutedActionMetadata) ByteString(com.google.protobuf.ByteString)

Aggregations

ByteString (com.google.protobuf.ByteString)3 Digest (build.bazel.remote.execution.v2.Digest)2 OutputDirectory (build.bazel.remote.execution.v2.OutputDirectory)2 OutputFile (build.bazel.remote.execution.v2.OutputFile)2 EntryLimitException (build.buildfarm.common.EntryLimitException)2 Action (build.bazel.remote.execution.v2.Action)1 ActionCacheUpdateCapabilities (build.bazel.remote.execution.v2.ActionCacheUpdateCapabilities)1 ActionResult (build.bazel.remote.execution.v2.ActionResult)1 Response (build.bazel.remote.execution.v2.BatchReadBlobsResponse.Response)1 BatchUpdateBlobsResponse (build.bazel.remote.execution.v2.BatchUpdateBlobsResponse)1 CacheCapabilities (build.bazel.remote.execution.v2.CacheCapabilities)1 Command (build.bazel.remote.execution.v2.Command)1 EnvironmentVariable (build.bazel.remote.execution.v2.Command.EnvironmentVariable)1 Directory (build.bazel.remote.execution.v2.Directory)1 DirectoryNode (build.bazel.remote.execution.v2.DirectoryNode)1 ExecuteOperationMetadata (build.bazel.remote.execution.v2.ExecuteOperationMetadata)1 ExecuteResponse (build.bazel.remote.execution.v2.ExecuteResponse)1 ExecutedActionMetadata (build.bazel.remote.execution.v2.ExecutedActionMetadata)1 ExecutionCapabilities (build.bazel.remote.execution.v2.ExecutionCapabilities)1 ExecutionPolicy (build.bazel.remote.execution.v2.ExecutionPolicy)1