diff options
author | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2019-06-19 10:40:09 +0100 |
---|---|---|
committer | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2019-06-26 16:43:50 +0100 |
commit | 5acd7b120acf9f4272aaed5779d535c3d6de473f (patch) | |
tree | f9a7509d4c9f3f8275c3bc2df07434a7ac9d29d7 | |
parent | d619bd876e4b098b3729d755824d6acee2cb57f6 (diff) | |
download | buildstream-5acd7b120acf9f4272aaed5779d535c3d6de473f.tar.gz |
_artifactcache.py: Use capabilities service
This is used in the remote initialisation to check that artifact service
is supported. This should allow us to seperate the endpoints of
different services more easily in future.
Part of #915
-rw-r--r-- | src/buildstream/_artifactcache.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/buildstream/_artifactcache.py b/src/buildstream/_artifactcache.py index 4a502064f..d62e7f500 100644 --- a/src/buildstream/_artifactcache.py +++ b/src/buildstream/_artifactcache.py @@ -23,7 +23,8 @@ import grpc from ._basecache import BaseCache from .types import _KeyStrength from ._exceptions import ArtifactError, CASError, CASCacheError -from ._protos.buildstream.v2 import artifact_pb2, artifact_pb2_grpc +from ._protos.buildstream.v2 import buildstream_pb2, buildstream_pb2_grpc, \ + artifact_pb2, artifact_pb2_grpc from ._cas import CASRemoteSpec, CASRemote from .storage._casbaseddirectory import CasBasedDirectory @@ -48,7 +49,7 @@ class ArtifactCacheSpec(CASRemoteSpec): class ArtifactRemote(CASRemote): def __init__(self, *args): super().__init__(*args) - self.artifact_service = None + self.capabilities_service = None def init(self): if not self._initialized: @@ -56,24 +57,28 @@ class ArtifactRemote(CASRemote): super().init() # Add artifact stub - self.artifact_service = artifact_pb2_grpc.ArtifactServiceStub(self.channel) + self.capabilities_service = buildstream_pb2_grpc.CapabilitiesStub(self.channel) # Check whether the server supports newer proto based artifact. try: - request = artifact_pb2.ArtifactStatusRequest() + request = buildstream_pb2.GetCapabilitiesRequest() if self.instance_name: request.instance_name = self.instance_name - self.artifact_service.ArtifactStatus(request) + response = self.capabilities_service.GetCapabilities(request) except grpc.RpcError as e: # Check if this remote has the artifact service if e.code() == grpc.StatusCode.UNIMPLEMENTED: raise ArtifactError( "Configured remote does not have the BuildStream " - "ArtifactService. Please check remote configuration.") + "capabilities service. Please check remote configuration.") # Else raise exception with details raise ArtifactError( "Remote initialisation failed: {}".format(e.details())) + if not response.artifact_capabilities: + raise ArtifactError( + "Configured remote does not support artifact service") + # An ArtifactCache manages artifacts. # |