summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-11-15 12:44:10 +0100
committerValentin David <valentin.david@codethink.co.uk>2018-11-28 15:29:52 +0100
commit58ca298ffd5e9d4f63af51223d3b6dc40826072b (patch)
tree7df0733293976813e532796eb9f577658c8796b7
parent26cdee087a690a4db66609d59fa14c656b98237d (diff)
downloadbuildstream-58ca298ffd5e9d4f63af51223d3b6dc40826072b.tar.gz
Make cache clients not fail when a blob is not available.
We plan to make cache incomplete. That is some blobs are missing. For most of cases we will delete references when requested if they are incomplete. But there will be corner cases where objects are removed after the reference is requested.
-rw-r--r--buildstream/_artifactcache/cascache.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py
index 315aa6afa..3218552fb 100644
--- a/buildstream/_artifactcache/cascache.py
+++ b/buildstream/_artifactcache/cascache.py
@@ -88,6 +88,13 @@ class CASRemoteSpec(namedtuple('CASRemoteSpec', 'url push server_cert client_key
CASRemoteSpec.__new__.__defaults__ = (None, None, None)
+class BlobNotFound(CASError):
+
+ def __init__(self, blob, msg):
+ self.blob = blob
+ super().__init__(msg)
+
+
# A CASCache manages a CAS repository as specified in the Remote Execution API.
#
# Args:
@@ -299,6 +306,8 @@ class CASCache():
raise CASError("Failed to pull ref {}: {}".format(ref, e)) from e
else:
return False
+ except BlobNotFound as e:
+ return False
# pull_tree():
#
@@ -1203,6 +1212,9 @@ class _CASBatchRead():
batch_response = self._remote.cas.BatchReadBlobs(self._request)
for response in batch_response.responses:
+ if response.status.code == code_pb2.NOT_FOUND:
+ raise BlobNotFound(response.digest.hash, "Failed to download blob {}: {}".format(
+ response.digest.hash, response.status.code))
if response.status.code != code_pb2.OK:
raise CASError("Failed to download blob {}: {}".format(
response.digest.hash, response.status.code))