buildgrid.server.cas.service module

CAS services

Implements the Content Addressable Storage API and ByteStream API.

class buildgrid.server.cas.service.ContentAddressableStorageService(server)

Bases: buildgrid._protos.build.bazel.remote.execution.v2.remote_execution_pb2_grpc.ContentAddressableStorageServicer

add_instance(name, instance)
FindMissingBlobs(request, context)

Determine if blobs are present in the CAS.

Clients can use this API before uploading blobs to determine which ones are already present in the CAS and do not need to be uploaded again.

There are no method-specific errors.

BatchUpdateBlobs(request, context)

Upload many blobs at once.

The server may enforce a limit of the combined total size of blobs to be uploaded using this API. This limit may be obtained using the [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. Requests exceeding the limit should either be split into smaller chunks or uploaded using the [ByteStream API][google.bytestream.ByteStream], as appropriate.

This request is equivalent to calling a Bytestream Write request on each individual blob, in parallel. The requests may succeed or fail independently.

Errors:

  • INVALID_ARGUMENT: The client attempted to upload more than the

server supported limit.

Individual requests may return the following errors, additionally:

  • RESOURCE_EXHAUSTED: There is insufficient disk quota to store the blob.

  • INVALID_ARGUMENT: The

[Digest][build.bazel.remote.execution.v2.Digest] does not match the provided data.

BatchReadBlobs(request, context)

Download many blobs at once.

The server may enforce a limit of the combined total size of blobs to be downloaded using this API. This limit may be obtained using the [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. Requests exceeding the limit should either be split into smaller chunks or downloaded using the [ByteStream API][google.bytestream.ByteStream], as appropriate.

This request is equivalent to calling a Bytestream Read request on each individual blob, in parallel. The requests may succeed or fail independently.

Errors:

  • INVALID_ARGUMENT: The client attempted to read more than the

server supported limit.

Every error on individual read will be returned in the corresponding digest status.

GetTree(request, context)

Fetch the entire directory tree rooted at a node.

This request must be targeted at a [Directory][build.bazel.remote.execution.v2.Directory] stored in the [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] (CAS). The server will enumerate the Directory tree recursively and return every node descended from the root.

The GetTreeRequest.page_token parameter can be used to skip ahead in the stream (e.g. when retrying a partially completed and aborted request), by setting it to a value taken from GetTreeResponse.next_page_token of the last successfully processed GetTreeResponse).

The exact traversal order is unspecified and, unless retrieving subsequent pages from an earlier request, is not guaranteed to be stable across multiple invocations of GetTree.

If part of the tree is missing from the CAS, the server will return the portion present and omit the rest.

Errors:

  • NOT_FOUND: The requested tree root is not present in the CAS.

class buildgrid.server.cas.service.ByteStreamService(server)

Bases: buildgrid._protos.google.bytestream.bytestream_pb2_grpc.ByteStreamServicer

CAS_READ_REGEX = '^(.*?)/?(blobs/.*/[0-9]*)$'
CAS_WRITE_REGEX = '^(.*?)/?(uploads/.*/blobs/.*/[0-9]*)'
LOGSTREAM_READ_REGEX = '^(.*?)/?([^/]*/logStreams/.*)$'
LOGSTREAM_WRITE_REGEX = '^(.*?)/?([^/]*/logStreams/.*/.*)$'
add_instance(name, instance)
Read(request, context)

Read() is used to retrieve the contents of a resource as a sequence of bytes. The bytes are returned in a sequence of responses, and the responses are delivered as the results of a server-side streaming RPC.

Write(requests, context)

Write() is used to send the contents of a resource as a sequence of bytes. The bytes are sent in a sequence of request protos of a client-side streaming RPC.

A Write() action is resumable. If there is an error or the connection is broken during the Write(), the client should check the status of the Write() by calling QueryWriteStatus() and continue writing from the returned committed_size. This may be less than the amount of data the client previously sent.

Calling Write() on a resource name that was previously written and finalized could cause an error, depending on whether the underlying service allows over-writing of previously written resources.

When the client closes the request channel, the service will respond with a WriteResponse. The service will not view the resource as complete until the client has sent a WriteRequest with finish_write set to true. Sending any requests on a stream after sending a request with finish_write set to true will cause an error. The client should check the WriteResponse it receives to determine how much data the service was able to commit and whether the service views the resource as complete or not.

QueryWriteStatus(request, context)

QueryWriteStatus() is used to find the committed_size for a resource that is being written, which can then be used as the write_offset for the next Write() call.

If the resource does not exist (i.e., the resource has been deleted, or the first Write() has not yet reached the service), this method returns the error NOT_FOUND.

The client may call QueryWriteStatus() at any time to determine how much data has been processed for this resource. This is useful if the client is buffering data and needs to know which data can be safely evicted. For any sequence of QueryWriteStatus() calls for a given resource name, the sequence of returned committed_size values will be non-decreasing.