summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-10-04 14:12:58 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-10-07 16:40:44 +0000
commitce4883b9ca2c050315d0a23694e0fd576e0a5005 (patch)
tree1a13e5a4f9f8e667432524324cb152d1d033864a
parentd67c70c7c01c56b47bb08b04b0dff931d8690a83 (diff)
downloadbuildstream-ce4883b9ca2c050315d0a23694e0fd576e0a5005.tar.gz
cascache.py: add a 'log_level' parameter and use it to run buildbox-casd
This changes how we instantiate the CASCache by reusing the log level parameters from BuildStream and forward them to buildbox-casd. By default, buildbox-casd will now have '--log-level warning', and --verbose will enable 'info' and --debug will enable 'trace'. This way, we can easily tweak buildbox-casd's verbosity
-rw-r--r--src/buildstream/_cas/__init__.py2
-rw-r--r--src/buildstream/_cas/cascache.py13
-rw-r--r--src/buildstream/_context.py12
3 files changed, 23 insertions, 4 deletions
diff --git a/src/buildstream/_cas/__init__.py b/src/buildstream/_cas/__init__.py
index 17e3a3fd9..3c6cd7db6 100644
--- a/src/buildstream/_cas/__init__.py
+++ b/src/buildstream/_cas/__init__.py
@@ -17,5 +17,5 @@
# Authors:
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
-from .cascache import CASCache
+from .cascache import CASCache, CASLogLevel
from .casremote import CASRemote
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index a62bc3d44..f7855afc4 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -38,6 +38,7 @@ from .._protos.build.bazel.remote.execution.v2 import remote_execution_pb2, remo
from .._protos.build.buildgrid import local_cas_pb2, local_cas_pb2_grpc
from .. import _signals, utils
+from ..types import FastEnum
from .._exceptions import CASCacheError
from .._message import Message, MessageType
@@ -52,6 +53,12 @@ _CACHE_USAGE_REFRESH = 5
_CASD_MAX_LOGFILES = 10
+class CASLogLevel(FastEnum):
+ WARNING = "warning"
+ INFO = "info"
+ TRACE = "trace"
+
+
# A CASCache manages a CAS repository as specified in the Remote Execution API.
#
# Args:
@@ -59,10 +66,13 @@ _CASD_MAX_LOGFILES = 10
# casd (bool): True to spawn buildbox-casd (default) or False (testing only)
# cache_quota (int): User configured cache quota
# protect_session_blobs (bool): Disable expiry for blobs used in the current session
+# log_level (LogLevel): Log level to give to buildbox-casd for logging
#
class CASCache():
- def __init__(self, path, *, casd=True, cache_quota=None, protect_session_blobs=True):
+ def __init__(
+ self, path, *, casd=True, cache_quota=None, protect_session_blobs=True, log_level=CASLogLevel.WARNING
+ ):
self.casdir = os.path.join(path, 'cas')
self.tmpdir = os.path.join(path, 'tmp')
os.makedirs(os.path.join(self.casdir, 'refs', 'heads'), exist_ok=True)
@@ -77,6 +87,7 @@ class CASCache():
casd_args = [utils.get_host_tool('buildbox-casd')]
casd_args.append('--bind=unix:' + self._casd_socket_path)
+ casd_args.append('--log-level=' + log_level.value)
if cache_quota is not None:
casd_args.append('--quota-high={}'.format(int(cache_quota)))
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index 52dcfbdcd..7ff993166 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -28,7 +28,7 @@ from ._profile import Topics, PROFILER
from ._platform import Platform
from ._artifactcache import ArtifactCache
from ._sourcecache import SourceCache
-from ._cas import CASCache
+from ._cas import CASCache, CASLogLevel
from .types import _CacheBuildTrees, _SchedulerErrorAction
from ._workspaces import Workspaces, WorkspaceProjectCache
from .node import Node
@@ -513,9 +513,17 @@ class Context():
def get_cascache(self):
if self._cascache is None:
+ if self.log_debug:
+ log_level = CASLogLevel.TRACE
+ elif self.log_verbose:
+ log_level = CASLogLevel.INFO
+ else:
+ log_level = CASLogLevel.WARNING
+
self._cascache = CASCache(self.cachedir,
casd=self.use_casd,
- cache_quota=self.config_cache_quota)
+ cache_quota=self.config_cache_quota,
+ log_level=log_level)
return self._cascache
# is_fork_allowed():