Repository navigation
worker: preserve container spec ordering after resolution - #5218
Conversation
7cc62a5 to
5671b2d
Compare
5671b2d to
ea12c7e
Compare
|
Well, the former approach wasn't gonna fly because the resolver normalizes the When I started digging deeper, I noticed we now have a handy |
As a part of osbuild/osbuild-composer#5218 I wanted to switch to the blocking resolver as we want to drop the async one going forward. However, it's not possible to set the auth file using the Resolver interface. Let's add a SetAuthFilePath method to the interface to fill this gap and unblock osbuild-composer's migration to the blocking resolver.
supakeen
left a comment
There was a problem hiding this comment.
Looks OK, small comment about losing the pipeline name.
However, it would be really nice to have a test that asserts the invariant introduced here so it doesn't get optimized away again in the future. I don't know how much work that would be if it's a lot then let's not bother and address the bug first.
Not a functional change, just preparing ground for changing the resolving logic in next commits.
container.Resolver.Finish() sorts results by digest so it's not guaranteed that it keeps the input order. However, osbuild-composer mistakenly started relying on keeping the order: For bootc-generic-iso with an iso_payload_reference, the os-tree pipeline carries two containers. If the payload container's digest sorts before the source container's, they end up in reversed positions, causing the payload to be deployed as the OS tree and vice versa. Fix this by switching to the new-ish Resolve() method of the resolver that does resolving synchronously. This allows us to neatly condense the 2 loops into 1 while making sure that the order is not changed. Kudos to @lucasgarfield for discovering the bug, and to @supakeen for finding out that the container refs get somewhere swapped.
Move resolver creation into the caller and pass it as a container.Resolver interface parameter. This makes the function testable with a mock resolver. No behaviour change.
ea12c7e to
74901f4
Compare
Add a test with a mock resolver that verifies ResolveContainers preserves the input ordering regardless of digest values. The os-tree pipeline carries two containers whose digests would sort in reverse order. Note that I had to make the ResolveContainers function public because it's in the main module so the test needs to be main_test.
74901f4 to
7ec73b6
Compare
|
You are right, @supakeen, I decided to use a simple |
As a part of osbuild/osbuild-composer#5218 I wanted to switch to the blocking resolver as we want to drop the async one going forward. However, it's not possible to set the auth file using the Resolver interface. Let's add a SetAuthFilePath method to the interface to fill this gap and unblock osbuild-composer's migration to the blocking resolver.
|
Needs a code owner approval from Tomas, but he's out. Merging anyway. |
container.Resolver.Finish() sorts results by digest so it's not guaranteed that it keeps the input order. However, osbuild-composer mistakenly started relying on keeping the order:
For bootc-generic-iso with an iso_payload_reference, the os-tree pipeline carries two containers. If the payload container's digest sorts before the source container's, they end up in reversed positions, causing the payload to be deployed as the OS tree and vice versa.
Fix this by switching to the new-ish Resolve() method of the resolver that does resolving synchronously. This allows us to neatly condense the 2 loops into 1 while making sure that the order is not changed.
Kudos to @lucasgarfield for discovering the bug, and to @supakeen for finding out that the container refs get somewhere swapped.