Skip to content

many: fix non-determistic manifest generation#2381

Merged
supakeen merged 1 commit into
osbuild:mainfrom
ondrejbudai:fix-map-ordering
May 28, 2026
Merged

many: fix non-determistic manifest generation#2381
supakeen merged 1 commit into
osbuild:mainfrom
ondrejbudai:fix-map-ordering

Conversation

@ondrejbudai

Copy link
Copy Markdown
Member

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.

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.
@ondrejbudai ondrejbudai requested a review from a team as a code owner May 28, 2026 13:16
@achilleas-k achilleas-k enabled auto-merge May 28, 2026 13:34
@achilleas-k achilleas-k added this pull request to the merge queue May 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 28, 2026

@supakeen supakeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@supakeen supakeen added this pull request to the merge queue May 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 28, 2026
@supakeen supakeen added this pull request to the merge queue May 28, 2026
Merged via the queue into osbuild:main with commit 2475250 May 28, 2026
25 checks passed

@lzap lzap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find, I swear to God I was running into random checksums on CI that I could not reproduce locally this might be it.

@lzap

lzap commented May 29, 2026

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants