Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/buildstream/_cas/casdprocessmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand All @@ -72,6 +73,7 @@ def __init__(
log_level,
cache_quota,
remote_cache_spec,
remote_action_cache_spec,
protect_session_blobs,
messenger,
*,
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/buildstream/_cas/casserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 22 additions & 1 deletion src/buildstream/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/buildstream/_frontend/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions src/buildstream/sandbox/_sandboxbuildboxrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
1 change: 1 addition & 0 deletions tests/testutils/casd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def casd_cache(path, messenger=None):
CASLogLevel.WARNING,
16 * 1024 * 1024,
None,
None,
True,
None,
)
Expand Down
Loading