fix inconsistent vendor package behaviour #608
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
when we introduced the prefixed vendored package behaviour we overlooked a case that could lead to inconstistent writes of the spec.lock for a prefixed package.
The issue was described in #606
The underlying cause was the ordering of
allInterestingPkgs
https://github.com/cloudfoundry/bosh-cli/pull/603/files#diff-420d09437c4bf08b4407d39b5956c6209df3519cde36b121a856085e372d2c92R240-R241As setup in the added test, we have 3 packages. The top level package
pkg-1
and the two dependencies it pulls inpkg-2,pkg-3
The ordering of the map
allInterestingPkgs
is inconsistent and the test will fail for every case where pkg-1 isn't the last item inallInterestingPkgs
. That is because we end up calling writeVendoredPackage on pkg-1, which in turn will iterate over the dependencies.At this point we didn't yet call .Prefix and .Finalize on the objects for
pkg-2
andpkg-3
. Though this is required so they can return their prefixed name via Name().This is addressed by duplicating the loop. The first pass will ensure all objects in the dependency tree are prefixed and finalized before the spec.lock is written to disk.