Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/osbuild-depsolve-dnf: enable loading of optional metadata #1775

Merged
merged 5 commits into from
May 28, 2024

Conversation

achilleas-k
Copy link
Member

@achilleas-k achilleas-k commented May 7, 2024

This is required so that callers can enable loading of filelists when using newer versions of libdnf with old repositories or packages that specify dependencies on files. For example, depsolving against RHEL 9.3 repos on Fedora 40 fails to resolve platform-python with the message

nothing provides /usr/libexec/platform-python needed by platform-python-...

Further reading:

@achilleas-k
Copy link
Member Author

Here's a small depsolve request that demonstrates the issue:

{
  "command": "depsolve",
  "arch": "x86_64",
  "module_platform_id": "platform:el9",
  "releasever": "9",
  "cachedir": "/tmp/rpmmd.cache",
  "arguments": {
    "repos": [
      {
        "id": "baseos",
        "name": "baseos",
        "baseurl": "https://rpmrepo.osbuild.org/v2/mirror/rhvpn/el9/el9-x86_64-baseos-n9.3-20230808",
        "check_gpg": false
      },
      {
        "id": "appstream",
        "name": "appstream",
        "baseurl": "https://rpmrepo.osbuild.org/v2/mirror/rhvpn/el9/el9-x86_64-appstream-n9.3-20230808",
        "check_gpg": false
      }
    ],
    "transactions": [
      {
        "package-specs": [
          "insights-client"
        ]
      }
    ]
  }
}
$ rpm -qa "*dnf*"
dnf-data-4.19.2-1.fc40.noarch
libdnf-0.73.1-1.fc40.x86_64
python3-libdnf-0.73.1-1.fc40.x86_64
python3-dnf-4.19.2-1.fc40.noarch
dnf-4.19.2-1.fc40.noarch

$ ./osbuild-depsolve-dnf < ./depsolve.json
error depsolve
DepsolveError: There was a problem depsolving insights-client:
 Problem: conflicting requests
  - nothing provides /usr/libexec/platform-python needed by insights-client-3.2.0-1.el9.noarch from appstream
{"kind": "DepsolveError", "reason": "There was a problem depsolving insights-client: \n Problem: conflicting requests\n  - nothing provides /usr/libexec/platform-python needed by insights-client-3.2.0-1.el9.noarch from appstream"}

Make sure the cache directory is empty before testing.

@achilleas-k
Copy link
Member Author

Maybe this would be better as an option on the depsolve request so that we can get the speed and efficiency of depsolving without downloading filelists when we know we don't need them and still be able to depsolve older distro versions when we need to.

@bcl
Copy link
Contributor

bcl commented May 8, 2024

I think that's the best option, maybe even a generic option to control what metadata is needed, set by the distro definition. I wouldn't want to unnecessarily download them when they aren't needed -- I don't actually remember why I set it in the dnf5 version, it was likely just a side effect of trying to get things working with the current repos.

@achilleas-k achilleas-k marked this pull request as draft May 16, 2024 17:27
@achilleas-k achilleas-k marked this pull request as ready for review May 16, 2024 17:40
@achilleas-k
Copy link
Member Author

achilleas-k commented May 16, 2024

Made it an option for both dnf and dnf5. This is a change in the default behaviour for the dnf5 depsolver, but I think that's okay given we don't use it in prod yet.

Discussions on the name of the option are welcome.
Currently it's a boolean called repo-filelists.
Should we make it a list of strings that the caller can enable instead?

{
  "command": "depsolve",
  "arch": "...",
  "module_platform_id": "...",
  "cachedir": "...",
  "optional-metadata": ["comps", "filelists"],
  "arguments": {
    "repos": [ ... ],
    "transactions": [ ... ]
  }
}

@bcl
Copy link
Contributor

bcl commented May 20, 2024

I like the example above, optional-metadata seems fine, or extra-metadata maybe? Either one does a good job describing that it's adding, not overriding anything.

@achilleas-k
Copy link
Member Author

achilleas-k commented May 21, 2024

I think extra-metadata is clearer (extra) but optional-metadata matches the option name, which I like.
Difficult decision. I'll toss a coin and update the PR.

@achilleas-k
Copy link
Member Author

I went with optional-metadata to match the dnf option name and moved it to the arguments part of the request.

{
  "command": "depsolve",
  "arch": "...",
  "module_platform_id": "...",
  "cachedir": "...",
  "arguments": {
    "repos": [ ... ],
    "optional-metadata": ["comps", "filelists"],
    "transactions": [ ... ]
  }
}

Moving it to the arguments makes more sense since it is an option that is only relevant for the depsolve command.

@achilleas-k achilleas-k changed the title tools/osbuild-depsolve-dnf: enable loading of filelists tools/osbuild-depsolve-dnf: enable loading of optional metadata May 21, 2024
achilleas-k added a commit to achilleas-k/images that referenced this pull request May 21, 2024
New property on the arguments object that controls the types of metadata
to download for repositories and use when depsolving.

See osbuild/osbuild#1775
bcl
bcl previously approved these changes May 22, 2024
Copy link
Contributor

@bcl bcl left a comment

Choose a reason for hiding this comment

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

Looks good. Schutzbot not happy though, not really sure why.

@achilleas-k
Copy link
Member Author

Looks good. Schutzbot not happy though, not really sure why.

Happy now.

Copy link
Contributor

@mvo5 mvo5 left a comment

Choose a reason for hiding this comment

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

This looks nice! How much extra work would it be if the existing test_depsolve.py be extended to include the "optional-metadata" in the files and the test?

@achilleas-k
Copy link
Member Author

This looks nice! How much extra work would it be if the existing test_depsolve.py be extended to include the "optional-metadata" in the files and the test?

Not sure. I think it might be as simple as enabling the option (or not) and checking if the local cache includes any files called *filelists* (or not) after the depsolve.
Let me poke at it a bit and see.

Filelist repo metadata is required when using newer versions of libdnf
with old repositories or packages that specify dependencies on files.
For example, depsolving with RHEL 9.3 repos on Fedora 40 fails to
resolve platform-python with the message

  nothing provides /usr/libexec/platform-python needed by platform-python-...

Not loading filelists is beneficial because it greatly reduces the size
of the metadata to download.  Filelists were downloaded by default for
repositories in the past, but with newer versions of dnf/libdnf (in
Fedora 40), they are downloaded on-demand (e.g. when running a query
that requires file information).  Newer package guidelines prohibit
depending on file paths, so filelists are not needed for package
depsolving with newer distro repositories.

Add an 'optional-metadata' property to the 'arguments' object of the
depsolve request, so that callers can enable any optional metadata they
need.

Further reading:
- https://libdnf.readthedocs.io/en/stable/tutorial-py/#case-for-loading-the-filelists
- https://github.com/rpm-software-management/dnf/releases/tag/4.19.0
- https://dnf.readthedocs.io/en/stable/user_faq.html#starting-with-fedora-40-i-noticed-repository-metadata-is-synchronized-much-faster-what-happened
We originally enabled filelists unconditionally in dnf5.  Let's make it
optional as part of the 'optional-metadata' option in the arguments so
that the caller can decide if it's needed, for example when using dnf5
with older repositories that have packages with file dependencies, but
don't download them when they're not needed, since the filelists are
quite large.
Run depsolve tests both with and without adding filelists to optional
metadata.
Use a fresh cache for each depsolve in tests.  This will let us check if
filelists are downloaded or not according to the option.
When the filelists are enabled in the optional metadata, the local cache
for the depsolve will include a filelist file for each repository.
Count the files matching *filelists* using glob() and compare them with
the number of repositories when the option is enabled.
When the option is not enabled, there should be no filelists.
@achilleas-k
Copy link
Member Author

I added a test but there's a small issue. The test doesn't check for the version of dnf, so if it's run with a version older than 4.19.0, it will fail. It's also tricky to check which version we're testing against because in out GitHub tests we use tox, which sets up venvs, so if we import dnf to check its version, we'll be checking the version in the venv, but the test is actually run against the system dnf version because we shell out to osbuild-depsolve-dnf, which runs in the system-wide env.

@achilleas-k
Copy link
Member Author

achilleas-k commented May 27, 2024

I added a test but there's a small issue. The test doesn't check for the version of dnf, so if it's run with a version older than 4.19.0, it will fail. It's also tricky to check which version we're testing against because in out GitHub tests we use tox, which sets up venvs, so if we import dnf to check its version, we'll be checking the version in the venv, but the test is actually run against the system dnf version because we shell out to osbuild-depsolve-dnf, which runs in the system-wide env.

Now that I think about it, this might be an issue with release testing in EL9, though I'm not sure what tests we run there.

Perhaps we should exclude it here: tests/unit-tests/run-unit-tests.sh

Copy link
Contributor

@mvo5 mvo5 left a comment

Choose a reason for hiding this comment

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

Thank you!

tools/test/test_depsolve.py Show resolved Hide resolved
@mvo5 mvo5 enabled auto-merge (rebase) May 28, 2024 06:06
github-merge-queue bot pushed a commit to osbuild/images that referenced this pull request May 28, 2024
New property on the arguments object that controls the types of metadata
to download for repositories and use when depsolving.

See osbuild/osbuild#1775
Copy link
Contributor

@bcl bcl left a comment

Choose a reason for hiding this comment

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

Looks good!

@mvo5 mvo5 merged commit a7955e6 into osbuild:main May 28, 2024
40 checks passed
@achilleas-k achilleas-k deleted the dnf/load-filelists branch May 28, 2024 23:40
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.

None yet

3 participants