summaryrefslogtreecommitdiff
path: root/buildstream/_scheduler/jobs/cachesizejob.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 16:53:57 +0900
commit6db54c8f156ad66572e760c38b96bcc355f586a5 (patch)
tree3565612947bdcdc4fba11e7ca5ebef504dcb704b /buildstream/_scheduler/jobs/cachesizejob.py
parent335b2fdd56802e26f127703964846d5593eca6a3 (diff)
downloadbuildstream-6db54c8f156ad66572e760c38b96bcc355f586a5.tar.gz
_artifactcache: There shalt be only one cache size
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/_scheduler/jobs/cachesizejob.py')
-rw-r--r--buildstream/_scheduler/jobs/cachesizejob.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/buildstream/_scheduler/jobs/cachesizejob.py b/buildstream/_scheduler/jobs/cachesizejob.py
index 9c1a4bc97..68cd91331 100644
--- a/buildstream/_scheduler/jobs/cachesizejob.py
+++ b/buildstream/_scheduler/jobs/cachesizejob.py
@@ -32,9 +32,11 @@ class CacheSizeJob(Job):
return self._artifacts.compute_cache_size()
def parent_complete(self, success, result):
- self._artifacts.set_cache_size(result)
- if self._complete_cb:
- self._complete_cb(result)
+ if success:
+ self._artifacts.set_cache_size(result)
+
+ if self._complete_cb:
+ self._complete_cb(result)
def child_process_data(self):
return {}