summaryrefslogtreecommitdiff
path: root/src/buildstream/_cas
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-09-09 09:54:48 +0200
committerJürg Billeter <j@bitron.ch>2019-09-19 17:31:29 +0200
commit1a9749c4601acfccd107e724b698b0cc0b922d32 (patch)
tree3602356a9e796ba623baaa7846b5d4c4e4a7cdbd /src/buildstream/_cas
parent6bac764cbe87924636dbf58d46e5c2c692250de5 (diff)
downloadbuildstream-1a9749c4601acfccd107e724b698b0cc0b922d32.tar.gz
casremote.py: Do not directly communicate with CAS server
All communication with CAS servers should be proxied through buildbox-casd to allow connection sharing among job subprocesses. It is no longer needed to query the server capabilities as buildbox-casd already does that, so we can simply remove the code from BuildStream.
Diffstat (limited to 'src/buildstream/_cas')
-rw-r--r--src/buildstream/_cas/casremote.py68
1 files changed, 0 insertions, 68 deletions
diff --git a/src/buildstream/_cas/casremote.py b/src/buildstream/_cas/casremote.py
index b1266a897..8a0a488ba 100644
--- a/src/buildstream/_cas/casremote.py
+++ b/src/buildstream/_cas/casremote.py
@@ -1,9 +1,5 @@
-import grpc
-
from .._protos.google.rpc import code_pb2
-from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2, remote_execution_pb2_grpc
from .._protos.build.buildgrid import local_cas_pb2
-from .._protos.buildstream.v2 import buildstream_pb2, buildstream_pb2_grpc
from .._remote import BaseRemote
from .._exceptions import CASRemoteError
@@ -33,12 +29,6 @@ class CASRemote(BaseRemote):
super().__init__(spec, **kwargs)
self.cascache = cascache
- self.cas = None
- self.ref_storage = None
- self.batch_update_supported = None
- self.batch_read_supported = None
- self.capabilities = None
- self.max_batch_total_size_bytes = None
self.local_cas_instance_name = None
# check_remote
@@ -48,39 +38,6 @@ class CASRemote(BaseRemote):
# be called outside of init().
#
def _configure_protocols(self):
- self.cas = remote_execution_pb2_grpc.ContentAddressableStorageStub(self.channel)
- self.capabilities = remote_execution_pb2_grpc.CapabilitiesStub(self.channel)
- self.ref_storage = buildstream_pb2_grpc.ReferenceStorageStub(self.channel)
-
- # Figure out what batch sizes the server will accept, falling
- # back to our _MAX_PAYLOAD_BYTES
- self.max_batch_total_size_bytes = _MAX_PAYLOAD_BYTES
- try:
- request = remote_execution_pb2.GetCapabilitiesRequest()
- if self.instance_name:
- request.instance_name = self.instance_name
- response = self.capabilities.GetCapabilities(request)
- server_max_batch_total_size_bytes = response.cache_capabilities.max_batch_total_size_bytes
- if 0 < server_max_batch_total_size_bytes < self.max_batch_total_size_bytes:
- self.max_batch_total_size_bytes = server_max_batch_total_size_bytes
- except grpc.RpcError as e:
- # Simply use the defaults for servers that don't implement
- # GetCapabilities()
- if e.code() != grpc.StatusCode.UNIMPLEMENTED:
- raise
-
- # Check whether the server supports BatchReadBlobs()
- self.batch_read_supported = self._check_support(
- remote_execution_pb2.BatchReadBlobsRequest,
- self.cas.BatchReadBlobs
- )
-
- # Check whether the server supports BatchUpdateBlobs()
- self.batch_update_supported = self._check_support(
- remote_execution_pb2.BatchUpdateBlobsRequest,
- self.cas.BatchUpdateBlobs
- )
-
local_cas = self.cascache._get_local_cas()
request = local_cas_pb2.GetInstanceNameForRemoteRequest()
request.url = self.spec.url
@@ -95,31 +52,6 @@ class CASRemote(BaseRemote):
response = local_cas.GetInstanceNameForRemote(request)
self.local_cas_instance_name = response.instance_name
- # _check_support():
- #
- # Figure out if a remote server supports a given method based on
- # grpc.StatusCode.UNIMPLEMENTED and grpc.StatusCode.PERMISSION_DENIED.
- #
- # Args:
- # request_type (callable): The type of request to check.
- # invoker (callable): The remote method that will be invoked.
- #
- # Returns:
- # (bool) - Whether the request is supported.
- #
- def _check_support(self, request_type, invoker):
- try:
- request = request_type()
- if self.instance_name:
- request.instance_name = self.instance_name
- invoker(request)
- return True
- except grpc.RpcError as e:
- if not e.code() in (grpc.StatusCode.UNIMPLEMENTED, grpc.StatusCode.PERMISSION_DENIED):
- raise
-
- return False
-
# push_message():
#
# Push the given protobuf message to a remote.