Skip to content

Make ostree container image pull merge commit reproducible#1421

Merged
cgwalters merged 3 commits intobootc-dev:mainfrom
jlebon:pr/reproducible-pull
Jul 17, 2025
Merged

Make ostree container image pull merge commit reproducible#1421
cgwalters merged 3 commits intobootc-dev:mainfrom
jlebon:pr/reproducible-pull

Conversation

@jlebon
Copy link
Contributor

@jlebon jlebon commented Jul 17, 2025

ostree-ext/store: use BTreeMap for merge commit metadata

HashMap is unordered which means that the conversion to GVariant (and thus its serialization) is not reproducible since the conversion basically just maps to an GVariant array. That in turns means the commit hash itself is not reproducible.

All we really need to do is just swap it for a BTreeMap since all the types involved here implement ordering.


ostree-ext/store: don't include filtered files in metadata

Filtered files are only determined at the time we import a layer. So if that layer is already imported, we won't have that information available. That in turn means that the metadata is state-dependent, which in turn means that the commit digest is not reproducible.

We still want to provide the filtered files warning though. Just make this information part of the LayeredImageState object instead. The obvious downside of that is that now we only get that warning the first time the layer is imported and it's no longer part of the commit object itself.

One way to make this more sticky is to attach it to the individual layers' commits instead, and then the merge commit can coalesce them.

Related: #1346

`HashMap` is unordered which means that the conversion to GVariant
(and thus its serialization) is not reproducible since the conversion
basically just maps to an GVariant array. That in turns means the commit
hash itself is not reproducible.

All we really need to do is just swap it for a `BTreeMap` since all the
types involved here implement ordering.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the reproducibility of ostree container image pull by replacing HashMap with BTreeMap for commit metadata and decoupling state-dependent information. The changes are well-implemented and tested.

Filtered files are only determined at the time we import a layer.
So if that layer is already imported, we won't have that information
available. That in turn means that the metadata is state-dependent,
which in turn means that the commit digest is not reproducible.

We still want to provide the filtered files warning though. Just make
this information part of the LayeredImageState object instead. The
obvious downside of that is that now we only get that warning the first
time the layer is imported and it's no longer part of the commit object
itself.

One way to make this more sticky is to attach it to the individual
layers' commits instead, and then the merge commit can coalesce them.

Related: bootc-dev#1346
@jlebon jlebon force-pushed the pr/reproducible-pull branch from fc87107 to 073d23a Compare July 17, 2025 14:42
This is something that I've wanted many times. There's no easy way from
e.g. bash to convert an image ref into the escaped OSTree ref and so
it's always awkward to be able to tell what ref/commit was pulled down.

Let's just match podman here and add a `--digestfile` switch for this.
@jlebon jlebon force-pushed the pr/reproducible-pull branch from 073d23a to d47956a Compare July 17, 2025 15:19
Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Awesome thank you!

@cgwalters cgwalters merged commit c2dc021 into bootc-dev:main Jul 17, 2025
29 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/install Issues related to `bootc install`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants