[PATCH 7/7] S7904: Add disk space checks before build & deploy

Richard Maw richard.maw at codethink.co.uk
Tue Jun 4 17:52:47 BST 2013


The same check that cachedir and tempdir are large enough is used
for both build and build-morphology.

Deploy only checks for tempdir being large enough.
---
 morphlib/plugins/branch_and_merge_plugin.py |    7 +++++++
 morphlib/plugins/build_plugin.py            |    7 +++++++
 morphlib/plugins/deploy_plugin.py           |    9 +++++++++
 3 files changed, 23 insertions(+)

diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py
index 215ac6c..38e9ccc 100644
--- a/morphlib/plugins/branch_and_merge_plugin.py
+++ b/morphlib/plugins/branch_and_merge_plugin.py
@@ -1527,6 +1527,13 @@ class BranchAndMergePlugin(cliapp.Plugin):
             raise cliapp.AppException('morph build expects exactly one '
                                       'parameter: the system to build')
 
+        # Raise an exception if there is not enough space
+        morphlib.util.check_disk_available(
+            self.app.settings['tempdir'],
+            self.app.settings['tempdir-min-space'],
+            self.app.settings['cachedir'],
+            self.app.settings['cachedir-min-space'])
+
         system_name = args[0]
 
         # Deduce workspace and system branch and branch root repository.
diff --git a/morphlib/plugins/build_plugin.py b/morphlib/plugins/build_plugin.py
index 6583a6a..26a2317 100644
--- a/morphlib/plugins/build_plugin.py
+++ b/morphlib/plugins/build_plugin.py
@@ -36,6 +36,13 @@ class BuildPlugin(cliapp.Plugin):
 
         '''
 
+        # Raise an exception if there is not enough space
+        morphlib.util.check_disk_available(
+            self.app.settings['tempdir'],
+            self.app.settings['tempdir-min-space'],
+            self.app.settings['cachedir'],
+            self.app.settings['cachedir-min-space'])
+
         build_command = morphlib.buildcommand.BuildCommand(self.app)
         build_command = self.app.hookmgr.call('new-build-command',
                                               build_command)
diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py
index 7a6f2b9..574a5e0 100644
--- a/morphlib/plugins/deploy_plugin.py
+++ b/morphlib/plugins/deploy_plugin.py
@@ -66,6 +66,15 @@ class DeployPlugin(cliapp.Plugin):
             raise cliapp.AppException(
                 'Too few arguments to deploy command (see help)')
 
+        # Raise an exception if there is not enough space in tempdir
+        # / for the path and 0 for the minimum size is a no-op
+        # it exists because it is complicated to check the available
+        # disk space given dirs may be on the same device
+        morphlib.util.check_disk_available(
+            self.app.settings['tempdir'],
+            self.app.settings['tempdir-min-space'],
+            '/', 0)
+
         deployment_type = args[0]
         system_name = args[1]
         location = args[2]
-- 
1.7.10.4




More information about the baserock-dev mailing list