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
Ansible-galaxy API client ignoring latest and reads all versions #79467
Comments
Files identified in the description:
If these files are incorrect, please update the |
This happens because when multiple collections are installed, we need to find a version that is compatible with all requirements. Since Galaxy doesn't give versions in order, ansible-galaxy collects all of them. You can work around this by installing a specific version, like ansible-galaxy could possibly optimize this by checking first if the latest version would match all requirements and only retrieving versions if it doesn't. |
@s-hertel thanks for the info. I guess than that this API endpoint:
which offers this stanca: "latest_version": {
"version": "0.10.0",
"href": "https://galaxy.ansible.com/api/v2/collections/osism/services/versions/0.10.0/"
}, Is not used at the moment, am I correct? |
@tibeer That's correct. |
Thanks, I'll close this! |
@tibeer You could leave it open imo, it seems like a reasonable thing to improve. I may not get to it quickly, but if anyone else is interested in picking this up basically we'd just need to refactor this function https://github.com/ansible/ansible/blob/stable-2.14/lib/ansible/galaxy/dependency_resolution/providers.py#L309. Rather than immediately getting all versions https://github.com/ansible/ansible/blob/stable-2.14/lib/ansible/galaxy/dependency_resolution/providers.py#L331, first try with the |
I just ran into this issue. Was trying to determine why when downloading the community.general collection, my project sync was taking 17 minutes. Pinning it a specific version in my requirements file dropped the sync to 44 seconds. That is a huge difference. Was using command line galaxy to debug, and noticed that it was querying the dependency map for every single version (and there are a ton on that collection). With the number of versions only ever increasing going forward, I definitely think this needs to be implemented sooner rather than later. |
I would also note that if I don't specify a version, I would expect it to always pull the latest version, and only the latest version. That is also what it seems the documentation implies will happen (* = latest). If there is a dependency issue with that latest version, I would rather it failed and alerted me to such an issue, so that I can make note of if and can pin proper versions. What happens instead if there is a dependency issue, is that it downgrades it to an older version, without alerting us to the fact. So I think I am using the latest version of a collection, but instead I am not. I may have needed the latest version of that 1st collection for a reason and will spent time debugging why my playbook no longer works because I didn't know the version was downgraded. I would think the existing behavior should only be used if I specifically tell it I want a version greater than X or lower than Y, etc... If I tell you I want a compatible version between these 2 numbers (or between this version and the latest), then you should look for one, otherwise you should get only the version I specified or the latest if I didn't specify. |
I don't think I've seen any dependency resolvers in other ecosystems doing this. We use exactly the same dependency resolver used by Pip and the downgrading behavior you describe is typically referred to as "backtracking" which was one of the primary reasons to refactor the old less robust resolver Pip used to have before that. |
No, "*" == "any", not latest. |
Just an FYI the latest version isn’t always the highest version available. When testing all this when the client was developed the value showed the last uploaded version. This would be problematic with collections that might still be uploading versions. For example if 2.1.0 was published but then 2.0.1 was published after, the returned version here will he 2.0.1. |
The highest/latest version may also report pre-releases in the API. Pre-releases as of now aren't filtered by the API. |
Ah.. nevermind. I can't read. |
My bad, I wasn't specific about what API I was talking about. The galaxy web api 😀 |
As of now, there is nothing we can do here. galaxy_ng depends on pulp, and pulp is making additional changes to version sorting and latest in their code, and then potentially once that is completed, galaxy_ng would need to make changes on top of that. We've sped up install a lot in recent releases by no longer making API calls for every version, we only get a full list of versions, and only call the individual version API for the candidate we are going to install. We probably won't save much time by going down this route of consulting |
agreed :) |
Summary
When trying to install a ansible-galaxy collection, the API client ignores the latest version which is provided on the API endpoint: https://galaxy.ansible.com/api/v2/collections/osism/services/.
It rather skips that information and continues to the versions endpoint: https://galaxy.ansible.com/api/v2/collections/osism/services/versions/.
After doing this, every single version is fetched individually just to continue using the latest alphabetical version.
When one decides to change the versioning scheme (e.g. from previous vX.X.X to X.X.X) always the latest vX.X.X would still be used as it is ordered alphabetically by the client.
This might also be a misunderstanding on my side, but it seems quite awkward to me that every single version JSON manifest is fetched. On collections with a lot versions this introduces unnecessary delay and can even (as described before) lead to malfunctioning.
Issue Type
Bug Report
Component Name
ansible-galaxy
Ansible Version
Configuration
OS / Environment
macOS 13.0.1
Steps to Reproduce
Expected Results
Only the latest Version should be called, the output should look like this:
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: