diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-09-10 14:40:06 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-09-10 16:53:57 +0900 |
commit | 6db54c8f156ad66572e760c38b96bcc355f586a5 (patch) | |
tree | 3565612947bdcdc4fba11e7ca5ebef504dcb704b /buildstream/_scheduler/jobs | |
parent | 335b2fdd56802e26f127703964846d5593eca6a3 (diff) | |
download | buildstream-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')
-rw-r--r-- | buildstream/_scheduler/jobs/cachesizejob.py | 8 | ||||
-rw-r--r-- | buildstream/_scheduler/jobs/cleanupjob.py | 8 | ||||
-rw-r--r-- | buildstream/_scheduler/jobs/elementjob.py | 8 |
3 files changed, 10 insertions, 14 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 {} diff --git a/buildstream/_scheduler/jobs/cleanupjob.py b/buildstream/_scheduler/jobs/cleanupjob.py index 54d615952..c22ce3b98 100644 --- a/buildstream/_scheduler/jobs/cleanupjob.py +++ b/buildstream/_scheduler/jobs/cleanupjob.py @@ -32,9 +32,11 @@ class CleanupJob(Job): return self._artifacts.clean() def parent_complete(self, success, result): - self._artifacts.set_cache_size(result) - if self._complete_cb: - self._complete_cb() + if success: + self._artifacts.set_cache_size(result) + + if self._complete_cb: + self._complete_cb() def child_process_data(self): return {} diff --git a/buildstream/_scheduler/jobs/elementjob.py b/buildstream/_scheduler/jobs/elementjob.py index a010a6684..8ce5c062f 100644 --- a/buildstream/_scheduler/jobs/elementjob.py +++ b/buildstream/_scheduler/jobs/elementjob.py @@ -18,7 +18,6 @@ # from ruamel import yaml -from ..._platform import Platform from ..._message import Message, MessageType from .job import Job @@ -73,10 +72,6 @@ class ElementJob(Job): self._action_cb = action_cb # The action callable function self._complete_cb = complete_cb # The complete callable function - # Hold on to the artifact cache - platform = Platform.get_platform() - self._artifacts = platform.artifactcache - # Set the task wide ID for logging purposes self.set_task_id(element._get_unique_id()) @@ -114,10 +109,7 @@ class ElementJob(Job): data = {} workspace = self._element._get_workspace() - cache_size = self._artifacts.compute_cache_size() - if workspace is not None: data['workspace'] = workspace.to_dict() - data['cache_size'] = cache_size return data |