summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-01-02 10:42:39 +0200
committerLars Wirzenius <liw@liw.fi>2019-01-02 10:42:39 +0200
commitf47e49ebfd6bcda2e20e3251ef9bdf96016f8164 (patch)
treed7a1809cdcfe347b4aafe6e2556ce29290387d3b
parentd167338338d08748caa94799fb424ee35b6a0325 (diff)
downloadvmdb2-f47e49ebfd6bcda2e20e3251ef9bdf96016f8164.tar.gz
Change: cache all explicitly mounted filesystems, not just /
-rw-r--r--NEWS3
-rw-r--r--vmdb/plugins/mount_plugin.py2
-rw-r--r--vmdb/plugins/rootfs_cache_plugin.py26
3 files changed, 29 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index ddbbde0..c228134 100644
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,9 @@ Version 0.13.2+git, not yet released
This allows a rootfs tarball that is old to be used, without the
Packages files being too old to be usable.
+* The `cache_rootfs` step now caches all the explicitly mounted
+ filesystems, not just the root filesystem.
+
Version 0.13.2, released 2018-05-06
------------------------------------
diff --git a/vmdb/plugins/mount_plugin.py b/vmdb/plugins/mount_plugin.py
index 06c1464..2ef3ef1 100644
--- a/vmdb/plugins/mount_plugin.py
+++ b/vmdb/plugins/mount_plugin.py
@@ -66,7 +66,7 @@ class MountStepRunner(vmdb.StepRunnerInterface):
mount_point = tempfile.mkdtemp()
vmdb.runcmd(['mount', device, mount_point])
- state.tags.set_mount_point(tag, mount_point)
+ state.tags.set_mount_point(tag, mount_point, cached=True)
return mount_point
diff --git a/vmdb/plugins/rootfs_cache_plugin.py b/vmdb/plugins/rootfs_cache_plugin.py
index ba46d85..5c9a894 100644
--- a/vmdb/plugins/rootfs_cache_plugin.py
+++ b/vmdb/plugins/rootfs_cache_plugin.py
@@ -48,8 +48,32 @@ class MakeCacheStepRunner(vmdb.StepRunnerInterface):
opts = step.get('options', '--one-file-system').split()
if not tar_path:
raise Exception('--rootfs-tarball MUST be set')
+ dirs = self._find_cacheable_mount_points(state.tags, rootdir)
+
+ tags = state.tags
+ for tag in tags.get_tags():
+ vmdb.progress(
+ 'tag {} mounted {} cached {}'.format(
+ tag, tags.get_mount_point(tag), tags.is_cached(tag)))
+
+ vmdb.progress('caching rootdir'.format(rootdir))
+ vmdb.progress('caching relative {}'.format(dirs))
if not os.path.exists(tar_path):
- vmdb.runcmd(['tar'] + opts + ['-C', rootdir, '-caf', tar_path, '.'])
+ vmdb.runcmd(
+ ['tar'] + opts + ['-C', rootdir, '-caf', tar_path] + dirs)
+
+ def _find_cacheable_mount_points(self, tags, rootdir):
+ return list(sorted(
+ self._make_relative(rootdir, tags.get_mount_point(tag))
+ for tag in tags.get_tags()
+ if tags.is_cached(tag)
+ ))
+
+ def _make_relative(self, rootdir, dirname):
+ assert dirname == rootdir or dirname.startswith(rootdir + '/')
+ if dirname == rootdir:
+ return '.'
+ return dirname[len(rootdir) + 1:]
class UnpackCacheStepRunner(vmdb.StepRunnerInterface):