Skip to content

osbuild: do not write duplicated package IDs - #1312

Closed
mvo5 wants to merge 2 commits into
osbuild:mainfrom
mvo5:naive-do-not-write-multiple-rpms
Closed

mvo5 wants to merge 2 commits into
osbuild:mainfrom
mvo5:naive-do-not-write-multiple-rpms

Conversation

@mvo5

@mvo5 mvo5 commented Mar 11, 2025

Copy link
Copy Markdown
Contributor

This commit is a very naive fix to avoid writing duplicated packages
into the osbuild manifest. Writing multiple identical package ids
into the manifest is no real problem but with the new manifest
compare tooling it creates unneeded diffs (if there is reason
to do/allow duplicated IDs and I'm missing that my apologies,
I will close this of course).

This shows up in e.g. #1300

Note that this is incredible naive - the right thing to do here would
be to make the []rpmmd.PackageSpec a type that abstracts that
it is a list and has an "Add()" that will automatically de-dup. But
that would distract (a lot) from the yaml-ifaction so this naive
version first.

The PR also contains a test change in the second commit. This
is totally optional but I found it nicer to look at the expected data
structure to see what is going on and it feels nice to know exactly
what is going on and what is converted in the result. I.e. I was
surprised that we set "IgnoreSSL" to true in the test but the resulting
FilesInputSourceArrayRef does not contain this. In the old style of
the test less visible if it is not checked or not there. I don't see a
real downside, the previous test was also casting into the right types
already (so not using interfaces) but I will not fight over it and can
drop the commit.

mvo5 added 2 commits March 11, 2025 09:21
This commit is a very naive fix to avoid writing duplicated packages
into the osbuild manifest. Writing multiple identical package ids
into the manifest is no real problem but with the new manifest
compare tooling it creates unneeded diffs.
This commit reworks the TestNewRpmStageSourceFilesInputs to
check the result via a struct equal check. This makes the test
for duplication detection simpler and it also documents the
(somewhat nested) interface/types that actually end up in the
json.

@thozza thozza 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.

Thanks for the PR.

I have two comments:

  1. As far as I can tell, the duplication is not happening in practice. The duplication happens when we combine package sets (the base package set, extended with any packages needed for used customizations) with user-requested packages. However, this is the state only before we depsolve the package set. IOW, the depsolve request can contain the firewalld package multiple times, but the depsolving result will never contain duplicate packages. The reason that you are seeing this behavior is due to generating manifests without depsolving package sets in the gen-manifests-diff tool that you've recently introduced https://github.com/osbuild/images/blob/48252e2b3c67df5e92266e215552fd5088a42796/tools/gen-manifests-diff#L34

  2. Diffing manifests without depsolving package sets is OK for a quick check, but not enough as proof that nothing changed. I know that depsolving can take significant time, but from my point of view, it is a must if used to check changes to generated manifests when changing image definitions. Omitting depsolving skips at least the following code paths:

    • Enablement of the package gpgcheck based on the repo config.
    • Weak dependencies behavior can be turned on/off in ImageConfig on the image type level or at the distro level.

My point is that skipping depsolving is sometimes acceptable and is always nice as a quick check. However, one should decide to (not) depsolve intentionally and consider the implications. IMHO, diffing with depsolved package sets should be done at least once, as the last check to verify one's changes.

The same applies to skipping the resolution of containers and commits, but these are not used in every image type and are not part of each manifest generation.

IMHO, the correct place to fix the ID duplication is in the gen-manifests tool, which is "mocking" the depsolving. So in https://github.com/osbuild/images/blob/main/cmd/gen-manifests/main.go#L312

@mvo5

mvo5 commented Mar 12, 2025

Copy link
Copy Markdown
Contributor Author

Fair points, I will look into the mocked depsolver then

@mvo5 mvo5 closed this Mar 12, 2025
mvo5 added a commit to mvo5/images that referenced this pull request Mar 12, 2025
This is a better version of osbuild#1312
that moves the de-duplication of packages into the package depsolver
of gen-manifests. This is similar to how osbuild-depsolve-dnf works
that also will present a de-duplicated result.

Thanks to thozza for the suggestion to do it this way.
@mvo5

mvo5 commented Mar 12, 2025

Copy link
Copy Markdown
Contributor Author

[..]

2. Diffing manifests without depsolving package sets is OK for a quick check, but not enough as proof that nothing changed. I know that depsolving can take significant time, but from my point of view, it is a must if used to check changes to generated manifests when changing image definitions. Omitting depsolving skips at least the following code paths:
   
   * Enablement of the package gpgcheck based on the repo config.
   * Weak dependencies behavior can be turned on/off in `ImageConfig` on the image type level or at the distro level.

My point is that skipping depsolving is sometimes acceptable and is always nice as a quick check. However, one should decide to (not) depsolve intentionally and consider the implications. IMHO, diffing with depsolved package sets should be done at least once, as the last check to verify one's changes.
[..]

@thozza Thanks for these interesting and valid points. I wonder however if we can overcome these limitations? In the mockdepsover in gen-manifests we encode the repositories as pseudo packages so we could encode more (like pgchecks and weak-dep hangling). This is not "nice" but does give us assurance that nothing has changed and it is incredible quick, as pointed out in #1307 it takes only 3sec and 80mb of data which makes it practical to run as a unit test and as part of the normal dev iteration. Compared to the minutes/hours and 1GB+ of data the full run takes. Maybe we can not get rid of the full run but it seems worth exploring how close we can get, wdyt?

github-merge-queue Bot pushed a commit that referenced this pull request Mar 12, 2025
This is a better version of #1312
that moves the de-duplication of packages into the package depsolver
of gen-manifests. This is similar to how osbuild-depsolve-dnf works
that also will present a de-duplicated result.

Thanks to thozza for the suggestion to do it this way.
@thozza

thozza commented Mar 12, 2025

Copy link
Copy Markdown
Member

@thozza Thanks for these interesting and valid points. I wonder however if we can overcome these limitations? In the mockdepsover in gen-manifests we encode the repositories as pseudo packages so we could encode more (like pgchecks and weak-dep hangling). This is not "nice" but does give us assurance that nothing has changed and it is incredible quick, as pointed out in #1307 it takes only 3sec and 80mb of data which makes it practical to run as a unit test and as part of the normal dev iteration. Compared to the minutes/hours and 1GB+ of data the full run takes. Maybe we can not get rid of the full run but it seems worth exploring how close we can get, wdyt?

Yes, I can see the benefits of this approach and think that it is worth exploring. 👍

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.

2 participants