diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2014-01-20 14:53:38 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2014-01-22 11:30:13 +0000 |
commit | 4c1acc88e81971172f6dc5b0d31f1eb8471cd0d2 (patch) | |
tree | d069ffb1c48a46fa6f404a63e9613da86aa3e9ec | |
parent | e97bcc8c98377e70e99ace9975e650092311983b (diff) | |
download | morph-4c1acc88e81971172f6dc5b0d31f1eb8471cd0d2.tar.gz |
cache-key: Fix obscure cache key collision
If two systems with the same name (e.g. different repo/ref) depend on the
same strata, then it will collide with systems which depend on different
artifacts from that stratum, but the same number of artifacts.
For example, if you checkout an existing branch and change the artifacts
used by one of its strata, then your local changes won't be built.
This is because the 'kids' field lists artifacts it depends on by their
cache-key, which is now no longer sufficient to uniquely identify
artifacts. The same number of artifacts issue is from it listing cache
keys multiple times.
The fix for this is to include the artifact name, so the 'kids' field is
now a list of dicts, with artifact name and cache key.
This is a dict rather than a tuple so that the generated /baserock
metadata is more readable.
-rw-r--r-- | morphlib/cachekeycomputer.py | 3 | ||||
-rw-r--r-- | tests.as-root/run-in-artifact-with-different-artifacts.stderr | 2 | ||||
-rw-r--r-- | tests.build/bootstrap-mode.stdout | 4 |
3 files changed, 5 insertions, 4 deletions
diff --git a/morphlib/cachekeycomputer.py b/morphlib/cachekeycomputer.py index 1a20faf1..bb536f82 100644 --- a/morphlib/cachekeycomputer.py +++ b/morphlib/cachekeycomputer.py @@ -81,7 +81,8 @@ class CacheKeyComputer(object): keys = { 'env': self._filterenv(self._build_env.env), 'filename': artifact.source.filename, - 'kids': [self.compute_key(x) for x in artifact.dependencies], + 'kids': [{'artifact': a.name, 'cache-key': self.compute_key(a)} + for a in artifact.dependencies], 'metadata-version': artifact.metadata_version } diff --git a/tests.as-root/run-in-artifact-with-different-artifacts.stderr b/tests.as-root/run-in-artifact-with-different-artifacts.stderr index 236954f8..9241fbb5 100644 --- a/tests.as-root/run-in-artifact-with-different-artifacts.stderr +++ b/tests.as-root/run-in-artifact-with-different-artifacts.stderr @@ -1 +1 @@ -ERROR: Artifact TMP/cache/artifacts/4a8b7a698ae79f417b1ff1541b883bd9f99fdf287a0d1a4176e7353dbe51a5fa.stratum.linux-stratum-runtime cannot be extracted or mounted +ERROR: Artifact TMP/cache/artifacts/e8e771e742c8f2199bd9f1e29cbeca07dbd51dd8880136d6521093711d37d8bf.stratum.linux-stratum-runtime cannot be extracted or mounted diff --git a/tests.build/bootstrap-mode.stdout b/tests.build/bootstrap-mode.stdout index b59d0029..e1747b15 100644 --- a/tests.build/bootstrap-mode.stdout +++ b/tests.build/bootstrap-mode.stdout @@ -1,7 +1,7 @@ build-essential strata: -./5bbfd4cb94017e7b72e20ee4f91a76bed8085aa96176cf87ecce54ec71d5ddae.stratum.build-essential-devel +./2271bef9cb222b1fd49bd2bcf3da435e02b4e0ce9fdddbcdf9358f608f51b547.stratum.build-essential-devel ["xxxx.chunk.cc-devel", "xxxx.chunk.cc-doc"] -./c8fe8efd4f8c6edcd309bb2cf0a308c93dfd905bbff64be98c5b07f350951fde.stratum.build-essential-runtime +./2a908a170acf10b4e9e131a007c8f3f0fa4961a7227c60793b3550c107f4c312.stratum.build-essential-runtime ["xxxx.chunk.cc-bins", "xxxx.chunk.cc-libs", "xxxx.chunk.cc-locale", "xxxx.chunk.cc-misc"] hello-system: |