summaryrefslogtreecommitdiff
path: root/buildstream/_artifactcache/cascache.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-10 14:40:06 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-10 15:56:12 +0900
commit78499b7dfcaf962a6da221081be06760f7ea3637 (patch)
tree36a8fab6c37af17cc2d5773d366279c997a05bd3 /buildstream/_artifactcache/cascache.py
parent303240abdcd01acad5e5daeeda16e2e9bc5aa28b (diff)
downloadbuildstream-78499b7dfcaf962a6da221081be06760f7ea3637.tar.gz
_artifactcache: There shalt be only one cache sizetristan/fix-cache-exclusivity-1.2
This does a lot of house cleaning, finally bringing cache cleanup logic to a level of comprehensibility. Changes in this commit include: o _artifactcache/artifactcache.py: _cache_size, _cache_quota and _cache_lower_threshold are now all private variables. get_approximate_cache_size() is now get_cache_size() Added get_quota_exceeded() for the purpose of safely checking if we have exceeded the quota. set_cache_size() now asserts that the passed size is not None, it is not acceptable to set a None size cache anymore. o _artifactcache/cascache.py: No longer set the ArtifactCache 'cache_size' variable violently in the commit() method. Also the calculate_cache_size() method now unconditionally calculates the cache size, that is what it's for. o _scheduler/jobs/cachesizejob.py & _scheduler/jobs/cleanupjob.py: Now check the success status. Don't try to set the cache size in the case that the job was terminated. o _scheduler/jobs/elementjob.py & _scheduler/queues/queue.py: No longer passing around the cache size from child tasks, this happens only explicitly, not implicitly for all tasks. o _scheduler/queues/buildqueue.py & _scheduler/scheduler.py: Use get_quota_exceeded() accessor This is a part of #623
Diffstat (limited to 'buildstream/_artifactcache/cascache.py')
-rw-r--r--buildstream/_artifactcache/cascache.py7
1 files changed, 1 insertions, 6 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py
index 099b252a5..4ef8723a3 100644
--- a/buildstream/_artifactcache/cascache.py
+++ b/buildstream/_artifactcache/cascache.py
@@ -120,8 +120,6 @@ class CASCache(ArtifactCache):
for ref in refs:
self.set_ref(ref, tree)
- self.cache_size = None
-
def diff(self, element, key_a, key_b, *, subdir=None):
ref_a = self.get_artifact_fullname(element, key_a)
ref_b = self.get_artifact_fullname(element, key_b)
@@ -488,10 +486,7 @@ class CASCache(ArtifactCache):
raise ArtifactError("Attempt to access unavailable artifact: {}".format(e)) from e
def calculate_cache_size(self):
- if self.cache_size is None:
- self.cache_size = utils._get_dir_size(self.casdir)
-
- return self.cache_size
+ return utils._get_dir_size(self.casdir)
# list_artifacts():
#