summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-04-02 18:34:34 +0300
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-04-02 18:34:34 +0300
commit26cffe6003460170c5eea15769979254efe2c00e (patch)
tree8cde1d04323155c489a3eeda1fc514ea553aca3e
parent5414a169bcc741fa822f37472381815efb5df17b (diff)
downloadmorph-baserock/danielsilverstone/distbuild-fiddling.tar.gz
reword: hideous patch to stop workers blowing their entire cache away every timebaserock/danielsilverstone/distbuild-fiddling
-rw-r--r--morphlib/plugins/distbuild_plugin.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/morphlib/plugins/distbuild_plugin.py b/morphlib/plugins/distbuild_plugin.py
index 27d87e35..a48e4aa1 100644
--- a/morphlib/plugins/distbuild_plugin.py
+++ b/morphlib/plugins/distbuild_plugin.py
@@ -89,12 +89,17 @@ class WorkerBuild(cliapp.Plugin):
artifact = distbuild.deserialise_artifact(serialized)
bc = morphlib.buildcommand.BuildCommand(self.app)
-
- # We always, unconditionally clear the local artifact cache
- # to avoid it growing boundlessly on a worker. Especially system
- # artifacts are big (up to gigabytes), and having a new one for
- # every build eats up a lot of disk space.
- bc.lac.clear()
+
+ # Now, before we start the build, we garbage collect the caches
+ # to ensure we have room. First we remove all system artifacts
+ # since we never need to recover those from workers post-hoc
+ for cachekey, artifacts, last_used in bc.lac.list_contents():
+ # This is horrible but...
+ if any(f.endswith("-rootfs") for f in artifacts):
+ logging.debug("Removing system artifact %s" % cachekey)
+ bc.lac.remove(cachekey)
+
+ self.app.subcommands['gc']([])
arch = artifact.arch
bc.build_artifact(artifact, bc.new_build_env(arch))