many: fix non-determistic manifest generation#2381
Merged
Conversation
We want manifests to be generated in a deterministic way. A common source of non-determinism is Go is iterating over maps - Go actually doesn't guarantee the iteration order. Thus, when creating an array from a map, we always need to sort the map deterministically before creating the array. My research found 3 places like this in the codebase, and this commit fixes them.
thozza
approved these changes
May 28, 2026
achilleas-k
approved these changes
May 28, 2026
supakeen
approved these changes
May 28, 2026
supakeen
left a comment
Member
There was a problem hiding this comment.
This kinda feels like the wrong places to do the sorting? It feels like this should live in the stages themselves or the manifest generator when it's serializing but it's also fine if it resolves an ongoing issue.
lzap
reviewed
May 29, 2026
lzap
left a comment
Contributor
There was a problem hiding this comment.
Nice find, I swear to God I was running into random checksums on CI that I could not reproduce locally this might be it.
Contributor
|
This got me curious how iteration in Go works through maps and it looks like Go always iterates in a slightly random order. This means that if there was any randomness, well, it is gone. I created a small test script and executed checksum regeneration 50 times and all good: #2382 |
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.
We want manifests to be generated in a deterministic way. A common source of non-determinism is Go is iterating over maps - Go actually doesn't guarantee the iteration order. Thus, when creating an array from a map, we always need to sort the map deterministically before creating the array.
My research found 3 places like this in the codebase, and this commit fixes them.