summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-09-05 05:47:14 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-09-05 05:47:14 +0000
commitd3cb30cecdccbdb65fea9d20989a57b461cfdeaf (patch)
treee63a5635c59b2d1fb91dfd6b3b3b1092b38874e0 /src
parent5c69b27c9c0271f947677a81b119656a7917a393 (diff)
parent45a177a305ec5babd6b1e3ac3fea2459f143eab2 (diff)
downloadbuildstream-d3cb30cecdccbdb65fea9d20989a57b461cfdeaf.tar.gz
Merge branch 'juerg/cache-usage' into 'master'
Display cache usage in status bar See merge request BuildStream/buildstream!1564
Diffstat (limited to 'src')
-rw-r--r--src/buildstream/_cas/cascache.py117
-rw-r--r--src/buildstream/_frontend/status.py35
-rw-r--r--src/buildstream/_protos/build/buildgrid/local_cas.proto18
-rw-r--r--src/buildstream/_protos/build/buildgrid/local_cas_pb2.py93
-rw-r--r--src/buildstream/_protos/build/buildgrid/local_cas_pb2_grpc.py17
5 files changed, 274 insertions, 6 deletions
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index 21c9f0ad6..b4bba2b6d 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -22,7 +22,9 @@ import os
import stat
import errno
import contextlib
+import multiprocessing
import shutil
+import signal
import subprocess
import tempfile
import time
@@ -42,7 +44,8 @@ from .casremote import BlobNotFound, _CASBatchRead, _CASBatchUpdate
_BUFFER_SIZE = 65536
-CACHE_SIZE_FILE = "cache_size"
+# Refresh interval for disk usage of local cache in seconds
+_CACHE_USAGE_REFRESH = 5
# A CASCache manages a CAS repository as specified in the Remote Execution API.
@@ -86,6 +89,7 @@ class CASCache():
self._casd_channel = None
self._local_cas = None
+ self._cache_usage_monitor = None
def __getstate__(self):
state = self.__dict__.copy()
@@ -145,6 +149,9 @@ class CASCache():
# Release resources used by CASCache.
#
def release_resources(self, messenger=None):
+ if self._cache_usage_monitor:
+ self._cache_usage_monitor.release_resources()
+
if self._casd_process:
if self._casd_channel:
self._local_cas = None
@@ -960,6 +967,114 @@ class CASCache():
# Upload any blobs missing on the server
self.send_blobs(remote, missing_blobs)
+ # get_cache_usage():
+ #
+ # Fetches the current usage of the CAS local cache.
+ #
+ # Returns:
+ # (CASCacheUsage): The current status
+ #
+ def get_cache_usage(self):
+ if not self._cache_usage_monitor:
+ self._cache_usage_monitor = _CASCacheUsageMonitor(self)
+
+ return self._cache_usage_monitor.get_cache_usage()
+
+
+# _CASCacheUsage
+#
+# A simple object to report the current CAS cache usage details.
+#
+# Args:
+# used_size (int): Total size used by the local cache, in bytes.
+# quota_size (int): Disk quota for the local cache, in bytes.
+#
+class _CASCacheUsage():
+
+ def __init__(self, used_size, quota_size):
+ self.used_size = used_size
+ self.quota_size = quota_size
+ if self.quota_size is None:
+ self.used_percent = 0
+ else:
+ self.used_percent = int(self.used_size * 100 / self.quota_size)
+
+ # Formattable into a human readable string
+ #
+ def __str__(self):
+ if self.used_size is None:
+ return "unknown"
+ elif self.quota_size is None:
+ return utils._pretty_size(self.used_size, dec_places=1)
+ else:
+ return "{} / {} ({}%)" \
+ .format(utils._pretty_size(self.used_size, dec_places=1),
+ utils._pretty_size(self.quota_size, dec_places=1),
+ self.used_percent)
+
+
+# _CASCacheUsageMonitor
+#
+# This manages the subprocess that tracks cache usage information via
+# buildbox-casd.
+#
+class _CASCacheUsageMonitor:
+ def __init__(self, cas):
+ self.cas = cas
+
+ # Shared memory (64-bit signed integer) for current disk usage and quota
+ self._disk_usage = multiprocessing.Value('q', -1)
+ self._disk_quota = multiprocessing.Value('q', -1)
+
+ # multiprocessing.Process will fork without exec on Unix.
+ # This can't be allowed with background threads or open gRPC channels.
+ assert utils._is_single_threaded() and not cas.has_open_grpc_channels()
+
+ self._subprocess = multiprocessing.Process(target=self._subprocess_run)
+ self._subprocess.start()
+
+ def get_cache_usage(self):
+ disk_usage = self._disk_usage.value
+ disk_quota = self._disk_quota.value
+
+ if disk_usage < 0:
+ # Disk usage still unknown
+ disk_usage = None
+
+ if disk_quota <= 0:
+ # No disk quota
+ disk_quota = None
+
+ return _CASCacheUsage(disk_usage, disk_quota)
+
+ def release_resources(self):
+ # Simply terminate the subprocess, no cleanup required in the subprocess
+ self._subprocess.terminate()
+
+ def _subprocess_run(self):
+ # Reset SIGTERM in subprocess to default as no cleanup is necessary
+ signal.signal(signal.SIGTERM, signal.SIG_DFL)
+
+ disk_usage = self._disk_usage
+ disk_quota = self._disk_quota
+ local_cas = self.cas._get_local_cas()
+
+ while True:
+ try:
+ # Ask buildbox-casd for current value
+ request = local_cas_pb2.GetLocalDiskUsageRequest()
+ response = local_cas.GetLocalDiskUsage(request)
+
+ # Update values in shared memory
+ disk_usage.value = response.size_bytes
+ disk_quota.value = response.quota_bytes
+ except grpc.RpcError:
+ # Terminate loop when buildbox-casd becomes unavailable
+ break
+
+ # Sleep until next refresh
+ time.sleep(_CACHE_USAGE_REFRESH)
+
def _grouper(iterable, n):
while True:
diff --git a/src/buildstream/_frontend/status.py b/src/buildstream/_frontend/status.py
index d0070cef0..a68d0d04e 100644
--- a/src/buildstream/_frontend/status.py
+++ b/src/buildstream/_frontend/status.py
@@ -350,7 +350,7 @@ class _StatusHeader():
#
# Public members
#
- self.lines = 2
+ self.lines = 3
#
# Private members
@@ -413,7 +413,38 @@ class _StatusHeader():
line2 = self._centered(text, size, line_length, ' ')
- return line1 + '\n' + line2
+ #
+ # Line 3: Cache usage percentage report
+ #
+ # ~~~~~~ cache: 44.2G / 64G (69%) ~~~~~~
+ #
+ cas = self._context.get_cascache()
+ usage = cas.get_cache_usage()
+ usage_string = str(usage)
+
+ if usage.used_size is None:
+ # Cache usage is unknown
+ size = 0
+ text = ''
+ else:
+ size = 21
+ size += len(usage_string)
+ if usage.used_percent >= 95:
+ formatted_usage = self._error_profile.fmt(usage_string)
+ elif usage.used_percent >= 80:
+ formatted_usage = self._content_profile.fmt(usage_string)
+ else:
+ formatted_usage = self._success_profile.fmt(usage_string)
+
+ text = self._format_profile.fmt("~~~~~~ ") + \
+ self._content_profile.fmt('cache') + \
+ self._format_profile.fmt(': ') + \
+ formatted_usage + \
+ self._format_profile.fmt(' ~~~~~~')
+
+ line3 = self._centered(text, size, line_length, ' ')
+
+ return line1 + '\n' + line2 + '\n' + line3
###################################################
# Private Methods #
diff --git a/src/buildstream/_protos/build/buildgrid/local_cas.proto b/src/buildstream/_protos/build/buildgrid/local_cas.proto
index 671caef0e..f2955f971 100644
--- a/src/buildstream/_protos/build/buildgrid/local_cas.proto
+++ b/src/buildstream/_protos/build/buildgrid/local_cas.proto
@@ -117,6 +117,9 @@ service LocalContentAddressableStorage {
// This returns a string that can be used as instance_name to access the
// specified endpoint in further requests.
rpc GetInstanceNameForRemote(GetInstanceNameForRemoteRequest) returns (GetInstanceNameForRemoteResponse) {}
+
+ // Query total space used by the local cache.
+ rpc GetLocalDiskUsage(GetLocalDiskUsageRequest) returns (GetLocalDiskUsageResponse) {}
}
// A request message for
@@ -371,3 +374,18 @@ message GetInstanceNameForRemoteRequest {
message GetInstanceNameForRemoteResponse {
string instance_name = 1;
}
+
+// A request message for
+// [LocalContentAddressableStorage.GetLocalDiskUsage][build.buildgrid.v2.LocalContentAddressableStorage.GetLocalDiskUsage].
+message GetLocalDiskUsageRequest {
+}
+
+// A response message for
+// [LocalContentAddressableStorage.GetLocalDiskUsage][build.buildgrid.v2.LocalContentAddressableStorage.GetLocalDiskUsage].
+message GetLocalDiskUsageResponse {
+ // Total size used by the local cache, in bytes.
+ int64 size_bytes = 1;
+
+ // Disk quota for the local cache, in bytes. A value of 0 means no quota is set.
+ int64 quota_bytes = 2;
+}
diff --git a/src/buildstream/_protos/build/buildgrid/local_cas_pb2.py b/src/buildstream/_protos/build/buildgrid/local_cas_pb2.py
index d1ef586f8..06df1385c 100644
--- a/src/buildstream/_protos/build/buildgrid/local_cas_pb2.py
+++ b/src/buildstream/_protos/build/buildgrid/local_cas_pb2.py
@@ -23,7 +23,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
package='build.buildgrid',
syntax='proto3',
serialized_options=None,
- serialized_pb=_b('\n\x1f\x62uild/buildgrid/local_cas.proto\x12\x0f\x62uild.buildgrid\x1a\x36\x62uild/bazel/remote/execution/v2/remote_execution.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/rpc/status.proto\"p\n\x18\x46\x65tchMissingBlobsRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12=\n\x0c\x62lob_digests\x18\x02 \x03(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\"\xcc\x01\n\x19\x46\x65tchMissingBlobsResponse\x12\x46\n\tresponses\x18\x01 \x03(\x0b\x32\x33.build.buildgrid.FetchMissingBlobsResponse.Response\x1ag\n\x08Response\x12\x37\n\x06\x64igest\x18\x01 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\"\n\x06status\x18\x02 \x01(\x0b\x32\x12.google.rpc.Status\"q\n\x19UploadMissingBlobsRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12=\n\x0c\x62lob_digests\x18\x02 \x03(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\"\xce\x01\n\x1aUploadMissingBlobsResponse\x12G\n\tresponses\x18\x01 \x03(\x0b\x32\x34.build.buildgrid.UploadMissingBlobsResponse.Response\x1ag\n\x08Response\x12\x37\n\x06\x64igest\x18\x01 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\"\n\x06status\x18\x02 \x01(\x0b\x32\x12.google.rpc.Status\"\x81\x01\n\x10\x46\x65tchTreeRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12<\n\x0broot_digest\x18\x02 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\x18\n\x10\x66\x65tch_file_blobs\x18\x03 \x01(\x08\"\x13\n\x11\x46\x65tchTreeResponse\"h\n\x11UploadTreeRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12<\n\x0broot_digest\x18\x02 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\"\x14\n\x12UploadTreeResponse\"u\n\x10StageTreeRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12<\n\x0broot_digest\x18\x02 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\x0c\n\x04path\x18\x03 \x01(\t\"!\n\x11StageTreeResponse\x12\x0c\n\x04path\x18\x01 \x01(\t\"U\n\x12\x43\x61ptureTreeRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x03(\t\x12\x1a\n\x12\x62ypass_local_cache\x18\x03 \x01(\x08\"\xd3\x01\n\x13\x43\x61ptureTreeResponse\x12@\n\tresponses\x18\x01 \x03(\x0b\x32-.build.buildgrid.CaptureTreeResponse.Response\x1az\n\x08Response\x12\x0c\n\x04path\x18\x01 \x01(\t\x12<\n\x0btree_digest\x18\x02 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\"\n\x06status\x18\x03 \x01(\x0b\x32\x12.google.rpc.Status\"V\n\x13\x43\x61ptureFilesRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x03(\t\x12\x1a\n\x12\x62ypass_local_cache\x18\x03 \x01(\x08\"\xd0\x01\n\x14\x43\x61ptureFilesResponse\x12\x41\n\tresponses\x18\x01 \x03(\x0b\x32..build.buildgrid.CaptureFilesResponse.Response\x1au\n\x08Response\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x37\n\x06\x64igest\x18\x02 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\"\n\x06status\x18\x03 \x01(\x0b\x32\x12.google.rpc.Status\"\x83\x01\n\x1fGetInstanceNameForRemoteRequest\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\x15\n\rinstance_name\x18\x02 \x01(\t\x12\x13\n\x0bserver_cert\x18\x03 \x01(\x0c\x12\x12\n\nclient_key\x18\x04 \x01(\x0c\x12\x13\n\x0b\x63lient_cert\x18\x05 \x01(\x0c\"9\n GetInstanceNameForRemoteResponse\x12\x15\n\rinstance_name\x18\x01 \x01(\t2\xc7\x06\n\x1eLocalContentAddressableStorage\x12l\n\x11\x46\x65tchMissingBlobs\x12).build.buildgrid.FetchMissingBlobsRequest\x1a*.build.buildgrid.FetchMissingBlobsResponse\"\x00\x12o\n\x12UploadMissingBlobs\x12*.build.buildgrid.UploadMissingBlobsRequest\x1a+.build.buildgrid.UploadMissingBlobsResponse\"\x00\x12T\n\tFetchTree\x12!.build.buildgrid.FetchTreeRequest\x1a\".build.buildgrid.FetchTreeResponse\"\x00\x12W\n\nUploadTree\x12\".build.buildgrid.UploadTreeRequest\x1a#.build.buildgrid.UploadTreeResponse\"\x00\x12X\n\tStageTree\x12!.build.buildgrid.StageTreeRequest\x1a\".build.buildgrid.StageTreeResponse\"\x00(\x01\x30\x01\x12Z\n\x0b\x43\x61ptureTree\x12#.build.buildgrid.CaptureTreeRequest\x1a$.build.buildgrid.CaptureTreeResponse\"\x00\x12]\n\x0c\x43\x61ptureFiles\x12$.build.buildgrid.CaptureFilesRequest\x1a%.build.buildgrid.CaptureFilesResponse\"\x00\x12\x81\x01\n\x18GetInstanceNameForRemote\x12\x30.build.buildgrid.GetInstanceNameForRemoteRequest\x1a\x31.build.buildgrid.GetInstanceNameForRemoteResponse\"\x00\x62\x06proto3')
+ serialized_pb=_b('\n\x1f\x62uild/buildgrid/local_cas.proto\x12\x0f\x62uild.buildgrid\x1a\x36\x62uild/bazel/remote/execution/v2/remote_execution.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/rpc/status.proto\"p\n\x18\x46\x65tchMissingBlobsRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12=\n\x0c\x62lob_digests\x18\x02 \x03(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\"\xcc\x01\n\x19\x46\x65tchMissingBlobsResponse\x12\x46\n\tresponses\x18\x01 \x03(\x0b\x32\x33.build.buildgrid.FetchMissingBlobsResponse.Response\x1ag\n\x08Response\x12\x37\n\x06\x64igest\x18\x01 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\"\n\x06status\x18\x02 \x01(\x0b\x32\x12.google.rpc.Status\"q\n\x19UploadMissingBlobsRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12=\n\x0c\x62lob_digests\x18\x02 \x03(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\"\xce\x01\n\x1aUploadMissingBlobsResponse\x12G\n\tresponses\x18\x01 \x03(\x0b\x32\x34.build.buildgrid.UploadMissingBlobsResponse.Response\x1ag\n\x08Response\x12\x37\n\x06\x64igest\x18\x01 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\"\n\x06status\x18\x02 \x01(\x0b\x32\x12.google.rpc.Status\"\x81\x01\n\x10\x46\x65tchTreeRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12<\n\x0broot_digest\x18\x02 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\x18\n\x10\x66\x65tch_file_blobs\x18\x03 \x01(\x08\"\x13\n\x11\x46\x65tchTreeResponse\"h\n\x11UploadTreeRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12<\n\x0broot_digest\x18\x02 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\"\x14\n\x12UploadTreeResponse\"u\n\x10StageTreeRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12<\n\x0broot_digest\x18\x02 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\x0c\n\x04path\x18\x03 \x01(\t\"!\n\x11StageTreeResponse\x12\x0c\n\x04path\x18\x01 \x01(\t\"U\n\x12\x43\x61ptureTreeRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x03(\t\x12\x1a\n\x12\x62ypass_local_cache\x18\x03 \x01(\x08\"\xd3\x01\n\x13\x43\x61ptureTreeResponse\x12@\n\tresponses\x18\x01 \x03(\x0b\x32-.build.buildgrid.CaptureTreeResponse.Response\x1az\n\x08Response\x12\x0c\n\x04path\x18\x01 \x01(\t\x12<\n\x0btree_digest\x18\x02 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\"\n\x06status\x18\x03 \x01(\x0b\x32\x12.google.rpc.Status\"V\n\x13\x43\x61ptureFilesRequest\x12\x15\n\rinstance_name\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x03(\t\x12\x1a\n\x12\x62ypass_local_cache\x18\x03 \x01(\x08\"\xd0\x01\n\x14\x43\x61ptureFilesResponse\x12\x41\n\tresponses\x18\x01 \x03(\x0b\x32..build.buildgrid.CaptureFilesResponse.Response\x1au\n\x08Response\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x37\n\x06\x64igest\x18\x02 \x01(\x0b\x32\'.build.bazel.remote.execution.v2.Digest\x12\"\n\x06status\x18\x03 \x01(\x0b\x32\x12.google.rpc.Status\"\x83\x01\n\x1fGetInstanceNameForRemoteRequest\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\x15\n\rinstance_name\x18\x02 \x01(\t\x12\x13\n\x0bserver_cert\x18\x03 \x01(\x0c\x12\x12\n\nclient_key\x18\x04 \x01(\x0c\x12\x13\n\x0b\x63lient_cert\x18\x05 \x01(\x0c\"9\n GetInstanceNameForRemoteResponse\x12\x15\n\rinstance_name\x18\x01 \x01(\t\"\x1a\n\x18GetLocalDiskUsageRequest\"D\n\x19GetLocalDiskUsageResponse\x12\x12\n\nsize_bytes\x18\x01 \x01(\x03\x12\x13\n\x0bquota_bytes\x18\x02 \x01(\x03\x32\xb5\x07\n\x1eLocalContentAddressableStorage\x12l\n\x11\x46\x65tchMissingBlobs\x12).build.buildgrid.FetchMissingBlobsRequest\x1a*.build.buildgrid.FetchMissingBlobsResponse\"\x00\x12o\n\x12UploadMissingBlobs\x12*.build.buildgrid.UploadMissingBlobsRequest\x1a+.build.buildgrid.UploadMissingBlobsResponse\"\x00\x12T\n\tFetchTree\x12!.build.buildgrid.FetchTreeRequest\x1a\".build.buildgrid.FetchTreeResponse\"\x00\x12W\n\nUploadTree\x12\".build.buildgrid.UploadTreeRequest\x1a#.build.buildgrid.UploadTreeResponse\"\x00\x12X\n\tStageTree\x12!.build.buildgrid.StageTreeRequest\x1a\".build.buildgrid.StageTreeResponse\"\x00(\x01\x30\x01\x12Z\n\x0b\x43\x61ptureTree\x12#.build.buildgrid.CaptureTreeRequest\x1a$.build.buildgrid.CaptureTreeResponse\"\x00\x12]\n\x0c\x43\x61ptureFiles\x12$.build.buildgrid.CaptureFilesRequest\x1a%.build.buildgrid.CaptureFilesResponse\"\x00\x12\x81\x01\n\x18GetInstanceNameForRemote\x12\x30.build.buildgrid.GetInstanceNameForRemoteRequest\x1a\x31.build.buildgrid.GetInstanceNameForRemoteResponse\"\x00\x12l\n\x11GetLocalDiskUsage\x12).build.buildgrid.GetLocalDiskUsageRequest\x1a*.build.buildgrid.GetLocalDiskUsageResponse\"\x00\x62\x06proto3')
,
dependencies=[build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2.DESCRIPTOR,google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_rpc_dot_status__pb2.DESCRIPTOR,])
@@ -778,6 +778,68 @@ _GETINSTANCENAMEFORREMOTERESPONSE = _descriptor.Descriptor(
serialized_end=2034,
)
+
+_GETLOCALDISKUSAGEREQUEST = _descriptor.Descriptor(
+ name='GetLocalDiskUsageRequest',
+ full_name='build.buildgrid.GetLocalDiskUsageRequest',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=2036,
+ serialized_end=2062,
+)
+
+
+_GETLOCALDISKUSAGERESPONSE = _descriptor.Descriptor(
+ name='GetLocalDiskUsageResponse',
+ full_name='build.buildgrid.GetLocalDiskUsageResponse',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ _descriptor.FieldDescriptor(
+ name='size_bytes', full_name='build.buildgrid.GetLocalDiskUsageResponse.size_bytes', index=0,
+ number=1, type=3, cpp_type=2, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ serialized_options=None, file=DESCRIPTOR),
+ _descriptor.FieldDescriptor(
+ name='quota_bytes', full_name='build.buildgrid.GetLocalDiskUsageResponse.quota_bytes', index=1,
+ number=2, type=3, cpp_type=2, label=1,
+ has_default_value=False, default_value=0,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ serialized_options=None, file=DESCRIPTOR),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ serialized_options=None,
+ is_extendable=False,
+ syntax='proto3',
+ extension_ranges=[],
+ oneofs=[
+ ],
+ serialized_start=2064,
+ serialized_end=2132,
+)
+
_FETCHMISSINGBLOBSREQUEST.fields_by_name['blob_digests'].message_type = build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2._DIGEST
_FETCHMISSINGBLOBSRESPONSE_RESPONSE.fields_by_name['digest'].message_type = build_dot_bazel_dot_remote_dot_execution_dot_v2_dot_remote__execution__pb2._DIGEST
_FETCHMISSINGBLOBSRESPONSE_RESPONSE.fields_by_name['status'].message_type = google_dot_rpc_dot_status__pb2._STATUS
@@ -815,6 +877,8 @@ DESCRIPTOR.message_types_by_name['CaptureFilesRequest'] = _CAPTUREFILESREQUEST
DESCRIPTOR.message_types_by_name['CaptureFilesResponse'] = _CAPTUREFILESRESPONSE
DESCRIPTOR.message_types_by_name['GetInstanceNameForRemoteRequest'] = _GETINSTANCENAMEFORREMOTEREQUEST
DESCRIPTOR.message_types_by_name['GetInstanceNameForRemoteResponse'] = _GETINSTANCENAMEFORREMOTERESPONSE
+DESCRIPTOR.message_types_by_name['GetLocalDiskUsageRequest'] = _GETLOCALDISKUSAGEREQUEST
+DESCRIPTOR.message_types_by_name['GetLocalDiskUsageResponse'] = _GETLOCALDISKUSAGERESPONSE
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
FetchMissingBlobsRequest = _reflection.GeneratedProtocolMessageType('FetchMissingBlobsRequest', (_message.Message,), dict(
@@ -961,6 +1025,20 @@ GetInstanceNameForRemoteResponse = _reflection.GeneratedProtocolMessageType('Get
))
_sym_db.RegisterMessage(GetInstanceNameForRemoteResponse)
+GetLocalDiskUsageRequest = _reflection.GeneratedProtocolMessageType('GetLocalDiskUsageRequest', (_message.Message,), dict(
+ DESCRIPTOR = _GETLOCALDISKUSAGEREQUEST,
+ __module__ = 'build.buildgrid.local_cas_pb2'
+ # @@protoc_insertion_point(class_scope:build.buildgrid.GetLocalDiskUsageRequest)
+ ))
+_sym_db.RegisterMessage(GetLocalDiskUsageRequest)
+
+GetLocalDiskUsageResponse = _reflection.GeneratedProtocolMessageType('GetLocalDiskUsageResponse', (_message.Message,), dict(
+ DESCRIPTOR = _GETLOCALDISKUSAGERESPONSE,
+ __module__ = 'build.buildgrid.local_cas_pb2'
+ # @@protoc_insertion_point(class_scope:build.buildgrid.GetLocalDiskUsageResponse)
+ ))
+_sym_db.RegisterMessage(GetLocalDiskUsageResponse)
+
_LOCALCONTENTADDRESSABLESTORAGE = _descriptor.ServiceDescriptor(
@@ -969,8 +1047,8 @@ _LOCALCONTENTADDRESSABLESTORAGE = _descriptor.ServiceDescriptor(
file=DESCRIPTOR,
index=0,
serialized_options=None,
- serialized_start=2037,
- serialized_end=2876,
+ serialized_start=2135,
+ serialized_end=3084,
methods=[
_descriptor.MethodDescriptor(
name='FetchMissingBlobs',
@@ -1044,6 +1122,15 @@ _LOCALCONTENTADDRESSABLESTORAGE = _descriptor.ServiceDescriptor(
output_type=_GETINSTANCENAMEFORREMOTERESPONSE,
serialized_options=None,
),
+ _descriptor.MethodDescriptor(
+ name='GetLocalDiskUsage',
+ full_name='build.buildgrid.LocalContentAddressableStorage.GetLocalDiskUsage',
+ index=8,
+ containing_service=None,
+ input_type=_GETLOCALDISKUSAGEREQUEST,
+ output_type=_GETLOCALDISKUSAGERESPONSE,
+ serialized_options=None,
+ ),
])
_sym_db.RegisterServiceDescriptor(_LOCALCONTENTADDRESSABLESTORAGE)
diff --git a/src/buildstream/_protos/build/buildgrid/local_cas_pb2_grpc.py b/src/buildstream/_protos/build/buildgrid/local_cas_pb2_grpc.py
index 7ea06a3a7..8dfaec7f3 100644
--- a/src/buildstream/_protos/build/buildgrid/local_cas_pb2_grpc.py
+++ b/src/buildstream/_protos/build/buildgrid/local_cas_pb2_grpc.py
@@ -54,6 +54,11 @@ class LocalContentAddressableStorageStub(object):
request_serializer=build_dot_buildgrid_dot_local__cas__pb2.GetInstanceNameForRemoteRequest.SerializeToString,
response_deserializer=build_dot_buildgrid_dot_local__cas__pb2.GetInstanceNameForRemoteResponse.FromString,
)
+ self.GetLocalDiskUsage = channel.unary_unary(
+ '/build.buildgrid.LocalContentAddressableStorage/GetLocalDiskUsage',
+ request_serializer=build_dot_buildgrid_dot_local__cas__pb2.GetLocalDiskUsageRequest.SerializeToString,
+ response_deserializer=build_dot_buildgrid_dot_local__cas__pb2.GetLocalDiskUsageResponse.FromString,
+ )
class LocalContentAddressableStorageServicer(object):
@@ -189,6 +194,13 @@ class LocalContentAddressableStorageServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
+ def GetLocalDiskUsage(self, request, context):
+ """Query total space used by the local cache.
+ """
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
+ context.set_details('Method not implemented!')
+ raise NotImplementedError('Method not implemented!')
+
def add_LocalContentAddressableStorageServicer_to_server(servicer, server):
rpc_method_handlers = {
@@ -232,6 +244,11 @@ def add_LocalContentAddressableStorageServicer_to_server(servicer, server):
request_deserializer=build_dot_buildgrid_dot_local__cas__pb2.GetInstanceNameForRemoteRequest.FromString,
response_serializer=build_dot_buildgrid_dot_local__cas__pb2.GetInstanceNameForRemoteResponse.SerializeToString,
),
+ 'GetLocalDiskUsage': grpc.unary_unary_rpc_method_handler(
+ servicer.GetLocalDiskUsage,
+ request_deserializer=build_dot_buildgrid_dot_local__cas__pb2.GetLocalDiskUsageRequest.FromString,
+ response_serializer=build_dot_buildgrid_dot_local__cas__pb2.GetLocalDiskUsageResponse.SerializeToString,
+ ),
}
generic_handler = grpc.method_handlers_generic_handler(
'build.buildgrid.LocalContentAddressableStorage', rpc_method_handlers)