Fixing non-deterministic layer and metadata ordering during pack builder create#1600
Merged
sambhav merged 4 commits intobuildpacks:mainfrom Jan 22, 2023
Merged
Conversation
…he same order Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
d34507d to
60033e3
Compare
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1600 +/- ##
==========================================
+ Coverage 80.58% 80.59% +0.02%
==========================================
Files 156 156
Lines 10480 10489 +9
==========================================
+ Hits 8444 8453 +9
Misses 1534 1534
Partials 502 502
Flags with carried forward coverage won't be shown. Click here to find out more. |
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
Member
Author
|
@jkutner , @hone or @dfreilich If you can take a look at this PR will be great! |
sambhav
approved these changes
Jan 22, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
In order to fix the issue, I added a coupled of
Sortmethods invocation in two places:At
pkg/client/create_builder.go: I noticed that when we download the buildpacks modules, this process happens asynchronously and the correspondingBuildModuledependencies may have different orders before callingAddBuildpack(module). We added the sort at this point. That fixes the non-deterministic order in theio.buildpacks.builder.metadatalabels.At
internal/builder/builder.go: The order inRootFS.Layersis determined by the order in which theimage.AddLayerWithDiffIDis called. Sorting the modules before being added into the final image fixes that issue.Output
Before
Using the reproduction steps described in the issue, this is the output with the current pack version:
Diff .RootFS.Layers
Diff "io.buildpacks.builder.metadata"
After
After building my local pack instance with the changes included in this PR, I deleted the builders, recreated them and execute the same commands showed above.
No difference were found by the
diffcommandResolves #1453
Signed-off-by: Juan Bustamante jbustamante@vmware.com