summaryrefslogtreecommitdiff
path: root/src/buildstream/_scheduler
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-06-06 15:38:16 +0200
committerJürg Billeter <j@bitron.ch>2019-08-20 07:41:23 +0200
commit147dd700fa9bf9634e23c8a38173ca49699570c6 (patch)
tree53e60145111dd5f83ff813b90c7dae870a57c542 /src/buildstream/_scheduler
parentfb0184dbf41ed98b2f69d84a847200d7df187107 (diff)
downloadbuildstream-147dd700fa9bf9634e23c8a38173ca49699570c6.tar.gz
_scheduler: Remove cleanup job
Cache expiry will be managed by buildbox-casd.
Diffstat (limited to 'src/buildstream/_scheduler')
-rw-r--r--src/buildstream/_scheduler/jobs/__init__.py1
-rw-r--r--src/buildstream/_scheduler/jobs/cleanupjob.py55
-rw-r--r--src/buildstream/_scheduler/scheduler.py53
3 files changed, 1 insertions, 108 deletions
diff --git a/src/buildstream/_scheduler/jobs/__init__.py b/src/buildstream/_scheduler/jobs/__init__.py
index 3e213171a..96062089f 100644
--- a/src/buildstream/_scheduler/jobs/__init__.py
+++ b/src/buildstream/_scheduler/jobs/__init__.py
@@ -19,5 +19,4 @@
from .elementjob import ElementJob
from .cachesizejob import CacheSizeJob
-from .cleanupjob import CleanupJob
from .job import JobStatus
diff --git a/src/buildstream/_scheduler/jobs/cleanupjob.py b/src/buildstream/_scheduler/jobs/cleanupjob.py
deleted file mode 100644
index 3e9a8ff47..000000000
--- a/src/buildstream/_scheduler/jobs/cleanupjob.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright (C) 2018 Codethink Limited
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library. If not, see <http://www.gnu.org/licenses/>.
-#
-# Author:
-# Tristan Daniël Maat <tristan.maat@codethink.co.uk>
-#
-from .job import Job, JobStatus, ChildJob
-
-
-class CleanupJob(Job):
- def __init__(self, *args, complete_cb, **kwargs):
- super().__init__(*args, **kwargs)
- self.set_name(self.action_name)
- self._complete_cb = complete_cb
-
- context = self._scheduler.context
- self._casquota = context.get_casquota()
-
- def handle_message(self, message):
- # Update the cache size in the main process as we go,
- # this provides better feedback in the UI.
- self._casquota.set_cache_size(message, write_to_disk=False)
-
- def parent_complete(self, status, result):
- if status is JobStatus.OK:
- self._casquota.set_cache_size(result, write_to_disk=False)
-
- if self._complete_cb:
- self._complete_cb(status, result)
-
- def create_child_job(self, *args, **kwargs):
- return ChildCleanupJob(*args, casquota=self._scheduler.context.get_casquota(), **kwargs)
-
-
-class ChildCleanupJob(ChildJob):
- def __init__(self, *args, casquota, **kwargs):
- super().__init__(*args, **kwargs)
- self._casquota = casquota
-
- def child_process(self):
- def progress():
- self.send_message(self._casquota.get_cache_size())
- return self._casquota.clean(progress)
diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py
index 17878c4fd..b191e7693 100644
--- a/src/buildstream/_scheduler/scheduler.py
+++ b/src/buildstream/_scheduler/scheduler.py
@@ -28,7 +28,7 @@ from contextlib import contextmanager
# Local imports
from .resources import Resources, ResourceType
-from .jobs import JobStatus, CacheSizeJob, CleanupJob
+from .jobs import JobStatus, CacheSizeJob
from .._profile import Topics, PROFILER
@@ -41,7 +41,6 @@ class SchedStatus():
# Some action names for the internal jobs we launch
#
-_ACTION_NAME_CLEANUP = 'clean'
_ACTION_NAME_CACHE_SIZE = 'size'
@@ -101,8 +100,6 @@ class Scheduler():
# State of cache management related jobs
self._cache_size_scheduled = False # Whether we have a cache size job scheduled
self._cache_size_running = None # A running CacheSizeJob, or None
- self._cleanup_scheduled = False # Whether we have a cleanup job scheduled
- self._cleanup_running = None # A running CleanupJob, or None
# Callbacks to report back to the Scheduler owner
self._interrupt_callback = interrupt_callback
@@ -340,53 +337,6 @@ class Scheduler():
[ResourceType.CACHE], 'cache-size'
)
- # Schedule a cleanup job if we've hit the threshold
- if status is not JobStatus.OK:
- return
-
- context = self.context
- artifacts = context.artifactcache
-
- if artifacts.full():
- self._cleanup_scheduled = True
-
- # Callback for the cleanup job
- def _cleanup_job_complete(self, status, cache_size):
-
- # Deallocate cleanup job resources
- self._cleanup_running = None
- self.resources.release([ResourceType.CACHE, ResourceType.PROCESS])
-
- # Unregister the exclusive interest when we're done with it
- if not self._cleanup_scheduled:
- self.resources.unregister_exclusive_interest(
- [ResourceType.CACHE], 'cache-cleanup'
- )
-
- # _sched_cleanup_job()
- #
- # Runs a cleanup job if one is scheduled to run now and
- # sufficient recources are available.
- #
- def _sched_cleanup_job(self):
-
- if self._cleanup_scheduled and self._cleanup_running is None:
-
- # Ensure we have an exclusive interest in the resources
- self.resources.register_exclusive_interest(
- [ResourceType.CACHE], 'cache-cleanup'
- )
-
- if self.resources.reserve([ResourceType.CACHE, ResourceType.PROCESS],
- [ResourceType.CACHE]):
-
- # Update state and launch
- self._cleanup_scheduled = False
- self._cleanup_running = \
- CleanupJob(self, _ACTION_NAME_CLEANUP, 'cleanup/cleanup',
- complete_cb=self._cleanup_job_complete)
- self._start_job(self._cleanup_running)
-
# _sched_cache_size_job()
#
# Runs a cache size job if one is scheduled to run now and
@@ -492,7 +442,6 @@ class Scheduler():
#
# Try the cache management jobs
#
- self._sched_cleanup_job()
self._sched_cache_size_job()
#