_context.py: Add support for storage-service in cache configuration
This allows use of a remote CAS server as cache. This is useful to
minimize disk usage of the local cache and to minimize downloads with
remote execution.
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index d5d0669..fc74745 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -175,6 +175,9 @@
# User specified cache quota, used for display messages
self.config_cache_quota_string: Optional[str] = None
+ # Remote cache server
+ self.remote_cache_spec: Optional[RemoteSpec] = None
+
# Whether or not to attempt to pull build trees globally
self.pull_buildtrees: Optional[bool] = None
@@ -343,7 +346,7 @@
# We need to find the first existing directory in the path of our
# casdir - the casdir may not have been created yet.
cache = defaults.get_mapping("cache")
- cache.validate_keys(["quota", "pull-buildtrees", "cache-buildtrees"])
+ cache.validate_keys(["quota", "storage-service", "pull-buildtrees", "cache-buildtrees"])
cas_volume = self.casdir
while not os.path.exists(cas_volume):
@@ -359,6 +362,10 @@
LoadErrorReason.INVALID_DATA,
) from e
+ remote_cache = cache.get_mapping("storage-service", default=None)
+ if remote_cache:
+ self.remote_cache_spec = RemoteSpec.new_from_node(remote_cache)
+
# Load global artifact cache configuration
cache_config = defaults.get_mapping("artifacts", default={})
self._global_artifact_cache_config = _CacheConfig.new_from_node(cache_config)
@@ -661,6 +668,7 @@
self.cachedir,
casd=self.use_casd,
cache_quota=self.config_cache_quota,
+ remote_cache_spec=self.remote_cache_spec,
log_level=log_level,
log_directory=self.logdir,
)
diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py
index 9994818..715f940 100644
--- a/src/buildstream/_frontend/widget.py
+++ b/src/buildstream/_frontend/widget.py
@@ -457,6 +457,11 @@
starttime = datetime.datetime.now()
text = ""
+ def format_spec(spec):
+ if spec.instance_name:
+ return "{} (instance: {})".format(spec.url, spec.instance_name)
+ return spec.url
+
self._resolved_keys = {element: element._get_cache_key() for element in stream.session_elements}
# Main invocation context
@@ -483,16 +488,15 @@
values["Maximum Build Tasks"] = context.sched_builders
values["Maximum Push Tasks"] = context.sched_pushers
values["Maximum Network Retries"] = context.sched_network_retries
+
+ if context.remote_cache_spec:
+ values["Cache Storage Service"] = format_spec(context.remote_cache_spec)
+
text += self._format_values(values)
if context.remote_execution_specs:
specs = context.remote_execution_specs
- def format_spec(spec):
- if spec.instance_name:
- return "{} (instance: {})".format(spec.url, spec.instance_name)
- return spec.url
-
text += "\n"
text += self.content_profile.fmt("Remote Execution Configuration\n", bold=True)
values = OrderedDict()