diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2018-11-15 12:44:10 +0100 |
---|---|---|
committer | Valentin David <valentin.david@codethink.co.uk> | 2018-11-19 14:11:56 +0100 |
commit | af6b0f5b70b623095065b58e1a1130ecf148b645 (patch) | |
tree | ab6cf8da97d4845ed17879c9b25c089e363c8760 | |
parent | 9126287e3f592d27569e2f46dc6f582a4e8924aa (diff) | |
download | buildstream-af6b0f5b70b623095065b58e1a1130ecf148b645.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.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py index ffeccc0b3..826468c6d 100644 --- a/buildstream/_artifactcache/cascache.py +++ b/buildstream/_artifactcache/cascache.py @@ -48,6 +48,13 @@ from . import ArtifactCache _MAX_PAYLOAD_BYTES = 1024 * 1024 +class BlobNotFound(ArtifactError): + + def __init__(self, blob, msg): + self.blob = blob + super().__init__(msg) + + # A CASCache manages artifacts in a CAS repository as specified in the # Remote Execution API. # @@ -259,6 +266,10 @@ class CASCache(ArtifactCache): element.info("Remote ({}) does not have {} cached".format( remote.spec.url, element._get_brief_display_key() )) + except BlobNotFound as e: + element.info("Remote ({}) does not have {} cached".format( + remote.spec.url, element._get_brief_display_key() + )) return False @@ -1079,6 +1090,9 @@ class _CASBatchRead(): batch_response = self._remote.cas.BatchReadBlobs(self._request) for response in batch_response.responses: + if response.status.code == grpc.StatusCode.NOT_FOUND.value[0]: + raise BlobNotFound(response.digest.hash, "Failed to download blob {}: {}".format( + response.digest.hash, response.status.code)) if response.status.code != grpc.StatusCode.OK.value[0]: raise ArtifactError("Failed to download blob {}: {}".format( response.digest.hash, response.status.code)) |