in src/buildstream/_elementsourcescache.py [0:0]
def pull(self, sources, plugin):
project = sources.get_project()
ref = sources.get_cache_key()
display_key = sources.get_brief_display_key()
uri = REMOTE_ASSET_SOURCE_URN_TEMPLATE.format(ref)
index_remotes, storage_remotes = self.get_remotes(project.name, False)
source_digest = None
errors = []
# Start by pulling our source proto, so that we know which
# blobs to pull
for remote in index_remotes:
remote.init()
try:
plugin.status("Pulling source {} <- {}".format(display_key, remote))
response = remote.fetch_blob([uri])
if response:
source_digest = response.blob_digest
break
plugin.info("Remote ({}) does not have source {} cached".format(remote, display_key))
except AssetCacheError as e:
plugin.warn("Could not pull from remote {}: {}".format(remote, e))
errors.append(e)
if errors and not source_digest:
raise SourceCacheError(
"Failed to pull source {}".format(display_key),
detail="\n".join(str(e) for e in errors),
temporary=True,
)
# If we don't have a source proto, we can't pull source files
if not source_digest:
return False
errors = []
for remote in storage_remotes:
remote.init()
try:
plugin.status("Pulling data for source {} <- {}".format(display_key, remote))
if self._pull_source_storage(ref, source_digest, remote):
plugin.info("Pulled source {} <- {}".format(display_key, remote))
return True
plugin.info("Remote ({}) does not have source {} cached".format(remote, display_key))
except BlobNotFound as e:
# Not all blobs are available on this remote
plugin.info("Remote cas ({}) does not have blob {} cached".format(remote, e.blob))
continue
except CASError as e:
plugin.warn("Could not pull from remote {}: {}".format(remote, e))
errors.append(e)
if errors:
raise SourceCacheError(
"Failed to pull source {}".format(display_key), detail="\n".join(str(e) for e in errors)
)
return False