-
Notifications
You must be signed in to change notification settings - Fork 24k
apt module, fix issue with packages not installing when pinned and cached #81364
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
base: devel
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs changelog and tests
This comment was marked as outdated.
This comment was marked as outdated.
@bcoca I need some help regarding the unit tests for this issue. For the unit test, I need multiple versions of a test debian package (e.g., https://ci-files.testing.ansible.com/test/integration/targets/dpkg_selections/hello_2.6-1_amd64.deb). Since, I don't have access to https://ci-files.testing.ansible.com I am not able to see what's available there. Can you please provide URLs for some test debian package that has at least three versions and which will not be wiped out in future. Thanks. |
no, we have none, i would recommend adding them as part of the test .. also this is something i would expect in an integration test, not a unit one. |
cc @mattclay |
The apt tests use a |
@bcoca I've tested foobar pkg (even with one additional version foobar-1.0.2) and that worked okay even without this pull request. So not sure how to reproduce the issue using foobar. I've added some tests to this pull request. My guess is the issue has something to do with non-std pkg versions such as '1.9.0-71-g9c1898a'. I'll try some more tests later. |
Also to explain the underlying issue, see lines:265-268 in for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; ++Ver)
{
if (Match.VersionMatches(Ver)) {
Pin *VP = VerPins + Ver->ID;
if (VP->Type == pkgVersionMatch::None) {
*VP = P;
matched = true;
}
}
} The priority pins are only updated if void pkgPolicy::SetPriority(pkgCache::VerIterator const &Ver, signed short Priority)
{
Pin pin;
pin.Data = "pkgPolicy::SetPriority";
pin.Priority = Priority;
VerPins[Ver->ID] = pin;
} |
774accb
to
7218cfe
Compare
@jhooda the CI failures look related to your patch: https://dev.azure.com/ansible/ansible/_build/results?buildId=86661&view=logs&j=26a6818c-7a55-5301-191d-87f9382f47e1&t=b498074a-badf-5058-76b3-ae0756883986&l=2586 — you need to fix them for the PR to be mergable. |
@webknjaz I reviewed the logs. They seem unrelated to my changes: my tests are further down from the failure point and the failure is in an unrelated "apt cache update" feature. I can try rebasing the pull request with the latest from the devel branch. Please suggest the way forward. Just for records "ansible [core 2.12.10]" does not suffer from this issue. |
This effectively means that your patch has side effects beyond what you expected, and it so happens that it breaks existing tests. Before this patch, If you're sure the patch is correct, the changes necessary might be in the tests, not in the module. |
Currently when apt cache holds multiple versions of the same package, including newer versions and older versions, a specific installation of the package version (other than the latest version) fails with an error message: no available installation candidate for <pkgname>=x.y.z However, the command line such as $ apt install <pkgname>=x.y.z works just fine, the reason being some issue in apt_cache.Policy which fails to override the default priority. When set_priority() is called before create_pin then it works as expected. Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
7218cfe
to
7c72d02
Compare
@webknjaz thanks for the suggestions. I have slightly changed apt.py and squashed commits too. Let's see if this helps. Thanks. |
@webknjaz I ran the test on my local Ubuntu22.04 LTS (devel branch - with last commit: f10d11b) and it failed exactly at the same place, so something else is causing the failure. The test which I ran
|
Try running with |
pkgver = next(v1 for v1 in pkg.version_list if v1.ver_str == version) | ||
policy.set_priority(pkgver, 0) | ||
except StopIteration: | ||
pass | ||
policy.create_pin('Version', pkgname, version, 1001) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this call modifies cache… Or maybe set_priority()
does?
Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
@jhooda could you rebase the PR branch, just in case the recent Launchpad API problems were related to the failure? |
@jhooda Could you please rebase this branch? Thanks in advance. |
@jhooda Any updates on the rebase? I just came across this issue while installing nodejs using nodesource, as it pins the repository origin:
|
SUMMARY
Currently when apt cache holds multiple versions of the same package, including newer versions and older versions, a specific installation of the package version (other than the latest version) fails with an error message:
However, the command line such as
works just fine, the reason being some issue in apt_cache.Policy which fails to override the default priority.
When
set_priority()
is called before create_pin then it works as expected.fixes #80813
ISSUE TYPE
COMPONENT NAME
modules/apt