diff --git a/src/buildstream/_cas/casdprocessmanager.py b/src/buildstream/_cas/casdprocessmanager.py index fd1692d9f..50a89124c 100644 --- a/src/buildstream/_cas/casdprocessmanager.py +++ b/src/buildstream/_cas/casdprocessmanager.py @@ -61,6 +61,7 @@ # cache_quota (int): User configured cache quota # reserved (int): User configured reserved disk space # remote_cache_spec (RemoteSpec): Optional remote cache server +# remote_action_cache_spec (RemoteSpec): Optional remote action cache server # protect_session_blobs (bool): Disable expiry for blobs used in the current session # messenger (Messenger): The messenger to report warnings through the UI # @@ -72,6 +73,7 @@ def __init__( log_level, cache_quota, remote_cache_spec, + remote_action_cache_spec, protect_session_blobs, messenger, *, @@ -140,6 +142,30 @@ def __init__( if remote_cache_spec.request_timeout is not None: casd_args.append("--cas-request-timeout={}".format(remote_cache_spec.request_timeout)) + if remote_action_cache_spec: + casd_args.append("--ac-remote={}".format(remote_action_cache_spec.url)) + if remote_action_cache_spec.instance_name: + casd_args.append("--ac-instance={}".format(remote_action_cache_spec.instance_name)) + if remote_action_cache_spec.server_cert_file: + casd_args.append("--ac-server-cert={}".format(remote_action_cache_spec.server_cert_file)) + if remote_action_cache_spec.client_key_file: + casd_args.append("--ac-client-key={}".format(remote_action_cache_spec.client_key_file)) + casd_args.append("--ac-client-cert={}".format(remote_action_cache_spec.client_cert_file)) + if remote_action_cache_spec.access_token_file: + casd_args.append("--ac-access-token={}".format(remote_action_cache_spec.access_token_file)) + if remote_action_cache_spec.access_token_reload_interval is not None: + casd_args.append( + "--ac-token-reload-interval={}".format(remote_action_cache_spec.access_token_reload_interval) + ) + if remote_action_cache_spec.keepalive_time is not None: + casd_args.append("--ac-keepalive-time={}".format(remote_action_cache_spec.keepalive_time)) + if remote_action_cache_spec.retry_limit is not None: + casd_args.append("--ac-retry-limit={}".format(remote_action_cache_spec.retry_limit)) + if remote_action_cache_spec.retry_delay is not None: + casd_args.append("--ac-retry-delay={}".format(remote_action_cache_spec.retry_delay)) + if remote_action_cache_spec.request_timeout is not None: + casd_args.append("--ac-request-timeout={}".format(remote_action_cache_spec.request_timeout)) + casd_args.append(path) self._start_time = time.time() diff --git a/src/buildstream/_cas/casserver.py b/src/buildstream/_cas/casserver.py index 72340ad7c..f593239b9 100644 --- a/src/buildstream/_cas/casserver.py +++ b/src/buildstream/_cas/casserver.py @@ -91,7 +91,7 @@ def create_server(repo, *, enable_push, quota, index_only, log_level=LogLevel.Le logger.addHandler(handler) casd = CASDProcessManager( - os.path.abspath(repo), os.path.join(os.path.abspath(repo), "logs"), log_level, quota, None, False, None + os.path.abspath(repo), os.path.join(os.path.abspath(repo), "logs"), log_level, quota, None, None, False, None ) try: diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py index 02942c8b0..85d72b82d 100644 --- a/src/buildstream/_context.py +++ b/src/buildstream/_context.py @@ -194,6 +194,9 @@ def __init__(self, *, use_casd: bool = True) -> None: # Remote cache server self.remote_cache_spec: Optional[RemoteSpec] = None + # Remote action cache server + self.remote_action_cache_spec: Optional[RemoteSpec] = None + # Whether or not to attempt to pull build trees globally self.pull_buildtrees: Optional[bool] = None @@ -369,7 +372,15 @@ def load(self, config: Optional[str] = None) -> None: # casdir - the casdir may not have been created yet. cache = defaults.get_mapping("cache") cache.validate_keys( - ["quota", "reserved-disk-space", "low-watermark", "storage-service", "pull-buildtrees", "cache-buildtrees"] + [ + "quota", + "reserved-disk-space", + "low-watermark", + "storage-service", + "action-cache-service", + "pull-buildtrees", + "cache-buildtrees", + ] ) cas_volume = self.casdir @@ -416,6 +427,15 @@ def load(self, config: Optional[str] = None) -> None: if remote_cache: self.remote_cache_spec = RemoteSpec.new_from_node(remote_cache) + remote_action_cache = cache.get_mapping("action-cache-service", default=None) + if remote_action_cache: + if not remote_cache: + raise LoadError( + "{}: 'action-cache-service' cannot be configured without 'storage-service'.".format(provenance), + LoadErrorReason.INVALID_DATA, + ) + self.remote_action_cache_spec = RemoteSpec.new_from_node(remote_action_cache) + # Load global artifact cache configuration cache_config = defaults.get_mapping("artifacts", default={}) self._global_artifact_cache_config = _CacheConfig.new_from_node(cache_config) @@ -741,6 +761,7 @@ def get_casd(self) -> CASDProcessManager: log_level, self.config_cache_quota, self.remote_cache_spec, + self.remote_action_cache_spec, protect_session_blobs=True, messenger=self.messenger, reserved=self.config_cache_reserved, diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py index 09b824ff3..b9c90f1e0 100644 --- a/src/buildstream/_frontend/widget.py +++ b/src/buildstream/_frontend/widget.py @@ -525,6 +525,8 @@ def format_spec(spec): if context.remote_cache_spec: values["Cache Storage Service"] = format_spec(context.remote_cache_spec) + if context.remote_action_cache_spec: + values["Action Cache Service"] = format_spec(context.remote_action_cache_spec) text += self._format_values(values) diff --git a/src/buildstream/sandbox/_sandboxbuildboxrun.py b/src/buildstream/sandbox/_sandboxbuildboxrun.py index d4b49860a..2f2735c0c 100644 --- a/src/buildstream/sandbox/_sandboxbuildboxrun.py +++ b/src/buildstream/sandbox/_sandboxbuildboxrun.py @@ -94,8 +94,10 @@ def _execute_action(self, action, flags): casd = cascache.get_casd() config = self._get_config() - if config.remote_apis_socket_path and context.remote_cache_spec: - raise SandboxError("'remote-apis-socket' is not currently supported with 'storage-service'.") + if config.remote_apis_socket_path and context.remote_cache_spec and not context.remote_action_cache_spec: + raise SandboxError( + "'remote-apis-socket' is not supported with 'storage-service' without 'action-cache-service'." + ) with utils._tempnamedfile() as action_file, utils._tempnamedfile() as result_file: action_file.write(action.SerializeToString()) diff --git a/tests/testutils/casd.py b/tests/testutils/casd.py index 403b3fc8e..74c40f9d0 100644 --- a/tests/testutils/casd.py +++ b/tests/testutils/casd.py @@ -25,6 +25,7 @@ def casd_cache(path, messenger=None): CASLogLevel.WARNING, 16 * 1024 * 1024, None, + None, True, None, )