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

ansible-galaxy fails to install collection from GalaxyNG when there are many versions #77911

Closed
1 task done
watsonb opened this issue May 25, 2022 · 21 comments · Fixed by #78325
Closed
1 task done

ansible-galaxy fails to install collection from GalaxyNG when there are many versions #77911

watsonb opened this issue May 25, 2022 · 21 comments · Fixed by #78325
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. P3 Priority 3 - Approved, No Time Limitation support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@watsonb
Copy link

watsonb commented May 25, 2022

Summary

Given I have installed GalaxyNG and published custom content and synchronized content from galaxy.ansible.com, when I try to install collections listed in a requirements.yml via a modern version of ansible-galaxy configured to use GalaxyNG, ansible-galaxy fails when encountering the community.vmware collection.

If you comment out community.vmware from requirements.yml, all other collections (custom published and synchronized) install fine.

If you uncomment community.vmware and use an older version of ansible-galaxy (e.g., Ansible 2.9.12), all collections install fine.

Issue Type

Bug Report

Component Name

ansible-galaxy

Ansible Version

$ ansible --version

# works (Ansible 2.9.12 installed via pip)
ansible 2.9.12
  config file = /home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg
  configured module search path = ['/home/ben/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ben/venv3_ansible-2.9.12/lib/python3.8/site-packages/ansible
  executable location = /home/ben/venv3_ansible-2.9.12/bin/ansible
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]

# fails (Ansible 4.2.0 installed via pip)
ansible [core 2.11.2] 
  config file = /home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg
  configured module search path = ['/home/ben/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ben/venv3_ansible-4.2.0/lib/python3.8/site-packages/ansible
  ansible collection location = /home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections:/home/ben/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ben/venv3_ansible-4.2.0/bin/ansible
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
  jinja version = 3.0.1
  libyaml = True

# fails (Ansible 5.8.0 installed via pip)
ansible [core 2.12.6]
  config file = /home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg
  configured module search path = ['/home/ben/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ben/venv3_ansible-5.8.0/lib/python3.8/site-packages/ansible
  ansible collection location = /home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections:/home/ben/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ben/venv3_ansible-5.8.0/bin/ansible
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True

Configuration

$ ansible-config dump --only-changed -t all
ANSIBLE_NOCOWS(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = True
CACHE_PLUGIN(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = $HOME/ansible/facts
CACHE_PLUGIN_TIMEOUT(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = 600
CALLBACKS_ENABLED(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = ['timer', 'profile_roles', 'profile_tasks', 'junit']
COLLECTIONS_PATHS(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = ['/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections', '/home/ben/.ansible/collections', '/usr/share/ansible/col>
DEFAULT_FORKS(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = 20
DEFAULT_GATHERING(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = smart
DEFAULT_INVENTORY_PLUGIN_PATH(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = ['/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/plugins/inventory', '/home/ben/.ansible/plugins/inventory',>
DEFAULT_LOAD_CALLBACK_PLUGINS(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = True
DEFAULT_ROLES_PATH(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = ['/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/roles', '/home/ben/.ansible/roles', '/usr/share/ansible/roles', '/etc/>
DEFAULT_STDOUT_CALLBACK(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = yaml
DEFAULT_VAULT_IDENTITY_LIST(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = ['vcenter@~/workspace/kiewit/ansible_vaults/vcenter', 'azure@~/workspace/kiewit/ansible_vaults/azure', 'ansible_use>
DEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /home/ben/workspace/kiewit/ansible_vaults/molecule
GALAXY_SERVER_LIST(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = ['kiewit_published', 'kiewit_community']
HOST_KEY_CHECKING(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = False
INVENTORY_ENABLED(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = ['host_list', 'script', 'auto', 'yaml', 'ini', 'toml', 'vmware_vm_inventory', 'azure_rm', 'ldap_inventory']
RETRY_FILES_ENABLED(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = True
VARIABLE_PRECEDENCE(/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg) = ['all_plugins_inventory', 'groups_plugins_inventory', 'all_inventory', 'groups_inventory', 'all_plugins_play', 'groups_plug>

OS / Environment

Ubuntu 20.04 running Ansible installed via pip into a virtual environment.

Steps to Reproduce

---
# requirements.yml

collections:
- name: azure.azcollection
  version: 1.7.0
- name: community.vmware
  version: 1.17.0
- name: community.general
  version: 4.5.0
- name: community.windows
  version: 1.9.0

# custom published collection
- name: kiewit.content
  version: 1.4.0
ansible-galaxy collection install -r collections/requirements.yml -p collections/ -vvvvv --force

GalaxyNG installed, custom collection published, remote collections synchronized to GalaxyNG via the following requirements.yml

---
collections:
- name: azure.azcollection
- name: community.vmware
- name: community.general
- name: community.windows

Notice there are 316 community.vmware versions:

image

Expected Results

I expect all listed requirements to be forcefully re-installed.

Actual Results

#
# Failing with `ansible-galaxy` via Ansible 5.8.0
#
ansible-galaxy [core 2.12.6]
  config file = /home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg
  configured module search path = ['/home/ben/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ben/venv3_ansible-5.8.0/lib/python3.8/site-packages/ansible
  ansible collection location = /home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections:/home/ben/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ben/venv3_ansible-5.8.0/bin/ansible-galaxy
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
  jinja version = 3.1.2
  libyaml = True
Using /home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg as config file
Reading requirement file at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/requirements.yml'
Starting galaxy collection install process
Found installed collection azure.azcollection:1.7.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/azure/azcollection'
Found installed collection ansible.windows:1.10.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/ansible/windows'
Found installed collection community.vmware:2.5.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/community/vmware'
Found installed collection community.general:4.5.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/community/general'
Found installed collection community.windows:1.9.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/community/windows'
Found installed collection kiewit.content:1.4.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/kiewit/content'
Process install dependency map
Initial connection to galaxy_server: https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/
Found API version 'v3' with Galaxy server kiewit_published (https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/)
Opened /home/ben/.ansible/galaxy_token
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/v3/collections/azure/azcollection/
Initial connection to galaxy_server: https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/
Found API version 'v3' with Galaxy server kiewit_community (https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/)
Opened /home/ben/.ansible/galaxy_token
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/collections/azure/azcollection/
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/v3/collections/community/vmware/
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/collections/community/vmware/
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/collections/community/vmware/versions/?limit=100
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/?limit=100&offset=100
[WARNING]: Skipping Galaxy server https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/. Got an unexpected error when getting available versions of collection community.vmware:
'/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/'
ERROR! Failed to resolve the requested dependencies map. Could not satisfy the following requirements:
* community.vmware:2.5.0 (direct request)

#
# Working via ansible-galaxy provided in Ansible 2.9.12
#
ansible-galaxy 2.9.12
  config file = /home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg
  configured module search path = ['/home/ben/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ben/venv3_ansible-2.9.12/lib/python3.8/site-packages/ansible
  executable location = /home/ben/venv3_ansible-2.9.12/bin/ansible-galaxy
  python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
Using /home/ben/workspace/kiewit/ansible/playbooks/ap_foo/ansible.cfg as config file
Reading requirement file at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/requirements.yml'
Found installed collection azure.azcollection:1.7.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/azure/azcollection'
Found installed collection ansible.windows:1.10.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/ansible/windows'
Found installed collection community.vmware:2.5.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/community/vmware'
Found installed collection community.general:4.5.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/community/general'
Found installed collection community.windows:1.9.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/community/windows'
Found installed collection kiewit.content:1.4.0 at '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/kiewit/content'
Process install dependency map
Initial connection to galaxy_server: https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/
Opened /home/ben/.ansible/galaxy_token
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/
Found API version 'v3' with Galaxy server kiewit_published (https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/)
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/v3/collections/azure/azcollection/versions/1.7.0/
Initial connection to galaxy_server: https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/
Opened /home/ben/.ansible/galaxy_token
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/
Processing requirement collection 'azure.azcollection'
Collection requirement 'azure.azcollection' is the name of a collection
Collection 'azure.azcollection' is not available from server kiewit_published https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/
Found API version 'v3' with Galaxy server kiewit_community (https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/)
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/collections/azure/azcollection/versions/1.7.0/
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/v3/collections/community/vmware/versions/2.5.0/
Collection 'azure.azcollection' obtained from server kiewit_community https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/
Processing requirement collection 'community.vmware'
Collection requirement 'community.vmware' is the name of a collection
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/collections/community/vmware/versions/2.5.0/
Collection 'community.vmware' is not available from server kiewit_published https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/v3/collections/community/general/versions/4.5.0/
Collection 'community.vmware' obtained from server kiewit_community https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/
Processing requirement collection 'community.general'
Collection requirement 'community.general' is the name of a collection
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/collections/community/general/versions/4.5.0/
Collection 'community.general' is not available from server kiewit_published https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/v3/collections/community/windows/versions/1.9.0/
Collection 'community.general' obtained from server kiewit_community https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/
Processing requirement collection 'community.windows'
Collection requirement 'community.windows' is the name of a collection
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/collections/community/windows/versions/1.9.0/
Collection 'community.windows' is not available from server kiewit_published https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/v3/collections/kiewit/content/versions/1.4.0/
Collection 'community.windows' obtained from server kiewit_community https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/
Processing requirement collection 'kiewit.content'
Collection requirement 'kiewit.content' is the name of a collection
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/collections/ansible/windows/versions/
Collection 'kiewit.content' obtained from server kiewit_published https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/
Processing requirement collection 'ansible.windows' - as dependency of community.windows
Collection requirement 'ansible.windows' is the name of a collection
Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/ansible/windows/versions/?limit=10&offset=10
Collection 'ansible.windows' obtained from server kiewit_community https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/
Starting collection install process
Installing 'azure.azcollection:1.7.0' to '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/azure/azcollection'
Downloading https://kneawxalp311.kiewitplaza.com/api/galaxy/v3/plugin/ansible/content/community/collections/artifacts/azure-azcollection-1.7.0.tar.gz to /home/ben/.ansible/tmp/ansible-local-20811912wtbig7j/tmp7pjnjmnu
Validating downloaded file hash 28041b95da141c55e01cc491f004b64cd9a7c7d2d28e622825543309744f689a with expected hash 28041b95da141c55e01cc491f004b64cd9a7c7d2d28e622825543309744f689a
Installing 'community.vmware:2.5.0' to '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/community/vmware'
Downloading https://kneawxalp311.kiewitplaza.com/api/galaxy/v3/plugin/ansible/content/community/collections/artifacts/community-vmware-2.5.0.tar.gz to /home/ben/.ansible/tmp/ansible-local-20811912wtbig7j/tmp7pjnjmnu
Validating downloaded file hash 4e3aaabdf4802af8ba9c08c77e464c1e0a52abcd7dec7d3aa51b1f865eadfe2a with expected hash 4e3aaabdf4802af8ba9c08c77e464c1e0a52abcd7dec7d3aa51b1f865eadfe2a
Installing 'community.general:4.5.0' to '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/community/general'
Downloading https://kneawxalp311.kiewitplaza.com/api/galaxy/v3/plugin/ansible/content/community/collections/artifacts/community-general-4.5.0.tar.gz to /home/ben/.ansible/tmp/ansible-local-20811912wtbig7j/tmp7pjnjmnu
Validating downloaded file hash c191817d1c19fef2ec2927d65dbec65f3f0bbba60523b95ec163a48ba39dbcf0 with expected hash c191817d1c19fef2ec2927d65dbec65f3f0bbba60523b95ec163a48ba39dbcf0
Installing 'community.windows:1.9.0' to '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/community/windows'
Downloading https://kneawxalp311.kiewitplaza.com/api/galaxy/v3/plugin/ansible/content/community/collections/artifacts/community-windows-1.9.0.tar.gz to /home/ben/.ansible/tmp/ansible-local-20811912wtbig7j/tmp7pjnjmnu
Validating downloaded file hash 63909e16fc055e39266127098f7c11e9da5e6000b231be5bdac74c1758ef9e9b with expected hash 63909e16fc055e39266127098f7c11e9da5e6000b231be5bdac74c1758ef9e9b
Installing 'kiewit.content:1.4.0' to '/home/ben/workspace/kiewit/ansible/playbooks/ap_foo/collections/ansible_collections/kiewit/content'
Downloading https://kneawxalp311.kiewitplaza.com/api/galaxy/v3/plugin/ansible/content/published/collections/artifacts/kiewit-content-1.4.0.tar.gz to /home/ben/.ansible/tmp/ansible-local-20811912wtbig7j/tmp7pjnjmnu
Validating downloaded file hash 5c72fee203e0e927ab7451cd0d7206c549f4280208f464ec0d5078711c70beda with expected hash 5c72fee203e0e927ab7451cd0d7206c549f4280208f464ec0d5078711c70beda
Skipping 'ansible.windows' as it is already installed

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot
Copy link
Contributor

ansibot commented May 25, 2022

Files identified in the description:

  • lib/ansible/galaxy

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 25, 2022
@watsonb
Copy link
Author

watsonb commented May 25, 2022

I think the big difference between the more modern ansible-galaxy and the older (working) version is this:

5.8.0

Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/?limit=100&offset=100

2.9.12

Calling Galaxy at https://kneawxalp311.kiewitplaza.com/api/galaxy/content/published/v3/collections/community/vmware/versions/2.5.0/

It seems the newer versions have an HTTP query string limiting the results whereas the older version does not. I cannot find a way to coerce ansible-galaxy to get past this limit of 100. I don't think this is a configuration/limitation imposed by GalaxyNG as it appears to work for older versions of ansible-galaxy.

@watsonb
Copy link
Author

watsonb commented May 25, 2022

I've worked around this by:

  1. delete community.vmware from GalaxyNG
  2. refine the requirements.yml used to configure GalaxyNG remote sync
  3. re-sync

My specific refinement uses a version qualifier for the community.vmware collection like so:

---
collections:
  - name: community.vmware
    version: '>= 1.17.0'

This greatly pared down the number of versions of the collection synced to GalaxyNG (I don't use anything older than 1.17.0) and now ansible-galaxy can install all collections specified in a requirements.yml in both older (Ansible 2.9.12) and more modern (Ansible 4.2.0+) versions of Ansible.

@mattclay mattclay added P3 Priority 3 - Approved, No Time Limitation and removed needs_triage Needs a first human triage before being processed. labels May 26, 2022
@s-hertel
Copy link
Contributor

@watsonb Would you be able to curl https://kneawxalp311.kiewitplaza.com/api/galaxy/content/community/v3/collections/community/vmware/versions/?limit=100 and share the value of links.next? I've been unable to reverse-engineer that to add a test that matches your output (well, unless links.next is actually /api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/?limit=100&offset=100, but I'm guessing not...).

needs_info

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label May 30, 2022
@watsonb
Copy link
Author

watsonb commented May 31, 2022

@s-hertel whilst using curl doesn't yield any results (not returning JSON for some reason), I am able to paste the URL into a browser and leverage the buil-in API viewer. Here's what comes back (mind you, this is after re-sync with a version qualifier to limit the number of sync'd versions).

{
    "meta": {
        "count": 9
    },
    "links": {
        "first": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/?limit=100&offset=0",
        "previous": null,
        "next": null,
        "last": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/?limit=100&offset=0"
    },
    "data": [
        {
            "version": "2.5.0",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/2.5.0/",
            "created_at": "2022-05-25T19:30:47.878318Z",
            "updated_at": "2022-05-25T19:30:47.878337Z",
            "requires_ansible": ">=2.11.0"
        },
        {
            "version": "2.4.0",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/2.4.0/",
            "created_at": "2022-05-25T19:30:47.878318Z",
            "updated_at": "2022-05-25T19:30:47.878337Z",
            "requires_ansible": ">=2.11.0"
        },
        {
            "version": "2.3.0",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/2.3.0/",
            "created_at": "2022-05-25T19:30:47.878318Z",
            "updated_at": "2022-05-25T19:30:47.878337Z",
            "requires_ansible": ">=2.11.0"
        },
        {
            "version": "2.2.0",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/2.2.0/",
            "created_at": "2022-05-25T19:30:47.878318Z",
            "updated_at": "2022-05-25T19:30:47.878337Z",
            "requires_ansible": ">=2.11.0"
        },
        {
            "version": "2.1.0",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/2.1.0/",
            "created_at": "2022-05-25T19:30:47.878318Z",
            "updated_at": "2022-05-25T19:30:47.878337Z",
            "requires_ansible": ">=2.11.0"
        },
        {
            "version": "2.0.0",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/2.0.0/",
            "created_at": "2022-05-25T19:30:47.878318Z",
            "updated_at": "2022-05-25T19:30:47.878337Z",
            "requires_ansible": ">=2.11.0"
        },
        {
            "version": "1.18.0",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/1.18.0/",
            "created_at": "2022-05-25T19:30:47.878318Z",
            "updated_at": "2022-05-25T19:30:47.878337Z",
            "requires_ansible": ">=2.9.10"
        },
        {
            "version": "1.17.1",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/1.17.1/",
            "created_at": "2022-05-25T19:30:47.878318Z",
            "updated_at": "2022-05-25T19:30:47.878337Z",
            "requires_ansible": ">=2.9.10"
        },
        {
            "version": "1.17.0",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/1.17.0/",
            "created_at": "2022-05-25T19:30:47.878318Z",
            "updated_at": "2022-05-25T19:30:47.878337Z",
            "requires_ansible": ">=2.9.10"
        }
    ]
}

That being said, I do have the full ansible.netcommon collection sync'd, which has 152 versions. I'll include a shortened version of that output below:

{
    "meta": {
        "count": 152
    },
    "links": {
        "first": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/ansible/netcommon/versions/?limit=100&offset=0",
        "previous": null,
        "next": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/ansible/netcommon/versions/?limit=100&offset=100",
        "last": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/ansible/netcommon/versions/?limit=100&offset=52"
    },
    "data": [
        {
            "version": "3.0.0",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/ansible/netcommon/versions/3.0.0/",
            "created_at": "2022-05-13T15:55:58.913107Z",
            "updated_at": "2022-05-13T15:55:58.913121Z",
            "requires_ansible": ">=2.9.10"
        },
        {
            "version": "2.6.1",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/ansible/netcommon/versions/2.6.1/",
            "created_at": "2022-05-13T15:55:58.913107Z",
            "updated_at": "2022-05-13T15:55:58.913121Z",
            "requires_ansible": ">=2.9.10"
        },
        {
            "href": "snipped for brevity"
        },
        {
            "version": "1.0.1-dev7",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/ansible/netcommon/versions/1.0.1-dev7/",
            "created_at": "2022-05-13T15:55:58.913107Z",
            "updated_at": "2022-05-13T15:55:58.913121Z",
            "requires_ansible": ">=2.9.10,<2.11"
        },
        {
            "version": "1.0.1-dev6",
            "href": "/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/ansible/netcommon/versions/1.0.1-dev6/",
            "created_at": "2022-05-13T15:55:58.913107Z",
            "updated_at": "2022-05-13T15:55:58.913121Z",
            "requires_ansible": ">=2.9.10,<2.11"
        }
    ]
}

This 100 limit "feels" to me like one tool ansible-galaxy or the other GalaxyNG isn't iterating over pages correctly to find the specified version of a collection that happens to be on a later page. It seems that GalaxyNG is serving these oldest to newest, and since community.vmware==1.17.0 wasn't on the first page (when I had all 316 versions), ansible-galaxy said it couldn't satisfy the requirements.

Now I feel like I should mention that I went back and did some experimenting with my older GalaxyNG 4.2.1 installation. I installed GalaxyNG 4.5.0 in a new VM "side-by-side" with my old install, because I could never get GalaxyNG 4.2.1 to sync my requirements.yml from galaxy.ansible.com. But I went back to 4.2.1 and started with smaller/simpler requirements.yml files. Lo and behold, with 1 or 2 collections in requirements.yml, GalaxyNG 4.2.1 was able to sync. However, if requirements.yml grew to include several collections (and I don't know what the real number is here), GalaxyNG 4.2.1 would fail to fully sync, often throwing some cryptic timeout and/or SSL errors.

I began resource monitoring GalaxyNG 4.2.1 via htop and noticed it was thrashing quite a bit when trying to sync the larger list of requirements. I went back to the GUI to edit the sync requirements again and noticed under the Advanced options, you could adjust the Download Concurrency (default is 10). I reduced that to 2, and kept the larger list of requirements for the sync and kicked it off again. I again monitored resource use via htop and it wasn't nearly as thrasy and, after quite some time, the sync process completed in Success.

Now here's the important bit that might help with root cause? GalaxyNG 4.2.1 apparently doesn't honor the version qualifiers in a requirements.yml from a sync point of view. I used the same requirements.yml that I used in 4.5.0 to limit the number of synced community.vmware versions, and 4.2.1 happily sync'ed all 316 versions anyway. Initially I was happy the sync worked, but then I thought, "Here we go with the version count issue again". Only, that isn't an issue with GalaxyNG 4.2.1. ansible-galaxy was able to install requirements from this 4.2.1 server using ansible==2.9.12, ansible==4.2.0, and ansible==5.8.0.

Below is a little table showing my success/failures across versions of things:

Ansible/GalaxyNG 4.2.1 4.5.0
2.9.12 pass pass
4.2.0 pass fail
5.8.0 pass fail

So this is a very version dependent issue and I'm not sure which tool is actually causing the problem, I'm merely reporting my experiences. Unfortunately, I cannot find a way to open an issue with the GalaxyNG team directly, as they use a different issue tracker.

Thanks for your time in looking!

@ansibot ansibot removed the needs_info This issue requires further information. Please answer any outstanding questions. label May 31, 2022
@bcoca
Copy link
Member

bcoca commented May 31, 2022

for any issues with galaxy.ansible.com go to https://github.com/ansible/galaxy/issues (which also hosts the older galaxy code, but it is still main interface for issues with the site).

https://github.com/ansible/galaxy_ng is the repo for the new code, but as you can see issues are disabled in github, but README has a link to https://issues.redhat.com/projects/AAH/issues

In any case this does look like an issue with the client, which means this is the correct repo to open it in.

@sivel
Copy link
Member

sivel commented Jun 1, 2022

Based on the next link, I'd have to guess there is either a misconfiguration in your galaxy_ng config, or a bug in galaxy_ng.

The next link from your curl seems to match what is failing:

/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/ansible/netcommon/versions/?limit=100&offset=100

I believe based on what the galaxy team provided us with, that should have instead been:

/api/v3/plugin/ansible/content/community/collections/index/ansible/netcommon/versions/?limit=100&offset=100

@sivel
Copy link
Member

sivel commented Jun 2, 2022

For the record, I've just launched galaxy_ng via this container: https://hub.docker.com/r/pulp/pulp-galaxy-ng

I edited the Remote community repository, and synced all of community.vmware and did not run into any issues, the install works as expected.

Starting galaxy collection install process
Process install dependency map
Initial connection to galaxy_server: http://localhost:8080/api/galaxy/content/community/
Calling Galaxy at http://localhost:8080/api/galaxy/content/community/
Found API version 'v3' with Galaxy server community_repo (http://localhost:8080/api/galaxy/content/community/)
Calling Galaxy at http://localhost:8080/api/galaxy/content/community/v3/collections/community/vmware/versions/?limit=100
Calling Galaxy at http://localhost:8080/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/?limit=100&offset=100
Calling Galaxy at http://localhost:8080/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/?limit=100&offset=200
Calling Galaxy at http://localhost:8080/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/?limit=100&offset=300
Calling Galaxy at http://localhost:8080/api/galaxy/content/community/v3/collections/community/vmware/versions/0.1.0/
[...]
Calling Galaxy at http://localhost:8080/api/galaxy/content/community/v3/collections/community/vmware/versions/2.5.0/
Starting collection install process
Fetching a collection tarball for 'community.vmware:2.5.0' from Ansible Galaxy
Downloading http://localhost:8080/api/galaxy/v3/plugin/ansible/content/community/collections/artifacts/community-vmware-2.5.0.tar.gz to /home/sivel/.ansible/tmp/ansible-local-42419u27b3fhg/tmpheer7rjj/community-vmware-2.5.0-26lsknq8
Validating downloaded file hash 4e3aaabdf4802af8ba9c08c77e464c1e0a52abcd7dec7d3aa51b1f865eadfe2a with expected hash 4e3aaabdf4802af8ba9c08c77e464c1e0a52abcd7dec7d3aa51b1f865eadfe2a
Collection 'community.vmware:2.5.0' obtained from server community_repo http://localhost:8080/api/galaxy/content/community/
Installing 'community.vmware:2.5.0' to '/home/sivel/projects/ansibledev/playbooks/pulp/tmp/ansible_collections/community/vmware'
community.vmware:2.5.0 was installed successfully

This is using galaxy_ng==4.5.0.


Can you try adding --no-cache to your install command, just to ensure it's not some caching issue? Outside of that, I think the only way to track this down is going to be having you insert some debugging code into your install.

@watsonb
Copy link
Author

watsonb commented Jun 2, 2022

Hmmm, interesting. I'll have to consult my playbook/notes. I'm installing onto a Rocky Linux 8.5 box using the pulp installer Ansible role. It was a challenge getting it to install, finding all of the versions of components that work together without dependency conflicts.

Here's what I ran to perform the install:

ansible-playbook playbooks/galaxy_ng_gist/enduser-install.yml \
  -i ~/workspace/kiewit/ansible/inventories/ae_kiewitplaza/awx3_ng.yml \
  --limit kneawxalp311.kiewitplaza.com \
  --extra-vars "@playbooks/galaxy_ng_gist/enduser-install-vars.yml" \
  -e pulp_version=3.18.5

This is using the playbooks/vars from the latest version of the GH gist.

Here are the vars:

pulp_default_admin_password: super_secret_password
pulp_install_source: pip
pulp_settings:
  secret_key: secret
  content_origin: "https://{{ inventory_hostname }}"
  x_pulp_api_host: 127.0.0.1
  x_pulp_api_port: 24817
  x_pulp_api_user: "admin"
  x_pulp_api_password: "{{ pulp_default_admin_password }}"
  x_pulp_api_prefix: "pulp_ansible/galaxy/automation-hub/api"
  galaxy_require_content_approval: "False"
  pulp_token_auth_disabled: "True"
  galaxy_api_default_distribution_base_path: "published"
pulp_install_plugins:
  pulp-ansible: {}
  galaxy-ng: {}
  pulp-container:
    version: 2.10.3
pulp_api_workers: 4
galaxy_importer_settings: {}

Using the pulp.pulp_installer collection version 3.19.1. I had to hack pulp.pulp_installer/roles/pulp_common/vars and change

# __pulpcore_version: '{{ pulpcore_version | default("3.19") }}'
__pulpcore_version: '{{ pulpcore_version | default("3.18.5") }}'

That being said, I hadn't considered a container-based installation.

@sivel
Copy link
Member

sivel commented Jun 2, 2022

This extra debugging may indicate what the issue is:

diff --git a/lib/ansible/galaxy/api.py b/lib/ansible/galaxy/api.py
index 55434f6d94..2aa7fe735b 100644
--- a/lib/ansible/galaxy/api.py
+++ b/lib/ansible/galaxy/api.py
@@ -380,6 +380,7 @@ class GalaxyAPI:
             resp = open_url(to_native(url), data=args, validate_certs=self.validate_certs, headers=headers,
                             method=method, timeout=self.timeout, http_agent=user_agent(), follow_redirects='safe')
         except HTTPError as e:
+            display.vvvv("Request failed (%r) due to status code %r: %r" % (e, e.code, e.read()))
             raise GalaxyError(e, error_context_msg)
         except Exception as e:
             raise AnsibleError("Unknown error when attempting to call Galaxy at '%s': %s" % (url, to_native(e)))

Also here are the versions installed in the container:

galaxy-ng==4.5.0
pulp-ansible==0.13.0
pulp-container==2.10.3
pulpcore==3.18.5

needs_info

@ansibot ansibot added the needs_info This issue requires further information. Please answer any outstanding questions. label Jun 6, 2022
@ephracis
Copy link

ephracis commented Jun 8, 2022

Hi,

I am the assigned Red Hat consultant for a customer and we recently hit this bug after an upgrade to AAP 2.2.

We have narrowed this issue down to the following stack trace:

Traceback (most recent call last):
  File "/usr/bin/ansible-galaxy", line 128, in <module>
    exit_code = cli.run()
  File "/usr/lib/python3.8/site-packages/ansible/cli/galaxy.py", line 569, in run
    return context.CLIARGS['func']()
  File "/usr/lib/python3.8/site-packages/ansible/cli/galaxy.py", line 86, in method_wrapper
    return wrapped_method(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/ansible/cli/galaxy.py", line 1203, in execute_install
    self._execute_install_collection(
  File "/usr/lib/python3.8/site-packages/ansible/cli/galaxy.py", line 1230, in _execute_install_collection
    install_collections(
  File "/usr/lib/python3.8/site-packages/ansible/galaxy/collection/__init__.py", line 548, in install_collections
    dependency_map = _resolve_depenency_map(
  File "/usr/lib/python3.8/site-packages/ansible/galaxy/collection/__init__.py", line 1364, in _resolve_depenency_map
    return collection_dep_resolver.resolve(
  File "/usr/lib/python3.8/site-packages/resolvelib/resolvers.py", line 453, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/usr/lib/python3.8/site-packages/resolvelib/resolvers.py", line 318, in resolve
    name, crit = self._merge_into_criterion(r, parent=None)
  File "/usr/lib/python3.8/site-packages/resolvelib/resolvers.py", line 173, in _merge_into_criterion
    crit = Criterion.from_requirement(self._p, requirement, parent)
  File "/usr/lib/python3.8/site-packages/resolvelib/resolvers.py", line 79, in from_requirement
    cands = build_iter_view(provider.find_matches([requirement]))
  File "/usr/lib/python3.8/site-packages/ansible/galaxy/dependency_resolution/providers.py", line 214, in find_matches
    coll_versions = self._api_proxy.get_collection_versions(first_req)
  File "/usr/lib/python3.8/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 101, in get_collection_versions
    return set(
  File "/usr/lib/python3.8/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 101, in <genexpr>
    return set(
  File "/usr/lib/python3.8/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 82, in _get_collection_versions
    raise last_error
  File "/usr/lib/python3.8/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 61, in _get_collection_versions
    versions = api.get_collection_versions(requirement.namespace, requirement.name)
  File "/usr/lib/python3.8/site-packages/ansible/galaxy/api.py", line 126, in wrapped
    return method(self, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/ansible/galaxy/api.py", line 869, in get_collection_versions
    data = self._call_galaxy(to_native(next_link, errors='surrogate_or_strict'),
  File "/usr/lib/python3.8/site-packages/ansible/module_utils/api.py", line 157, in run_function
    return call_retryable_function()
  File "/usr/lib/python3.8/site-packages/ansible/galaxy/api.py", line 396, in _call_galaxy
    path_cache = self._cache[cache_id][url_info.path]
KeyError: '/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/ansible/netcommon/versions/'

As far as I can tell the issue lies with the caching combined with the fact that Automation Hub 4.5.0 has changed the path for the collections. So when traversing >100 versions the dependency resolver fails and returns an empty list of candidates.

Possible workarounds we have found:

  • Use --no-cache when running ansible-galaxy from CLI. This skips the storing of the cache and thus avoid the issue.
  • Use a version constraint in the requirements definition in Automation Hub to limit the number of versions to <=100. This works when you have less control of ansible-galaxy such as when it is run by Automation Controller during a project sync.

@sivel
Copy link
Member

sivel commented Jun 8, 2022

@ephracis if you clear the cache, either by calling ansible-galaxy with --clear-response-cache or by deleting ~/.ansible/galaxy_cache/ does this error happen again?

Or does it only happen after upgrading to a version that uses a new URL, after already having a cache for an old URL?

I guess I'm curious whether this is just a result of an out of date cache, or whether there is an issue with our caching in general. It's not trivial to set up galaxy_ng to test this, so I haven't been able to reproduce.

@ephracis
Copy link

ephracis commented Jun 8, 2022

Resetting the cache has no effect. I believe the bug is when the cache is set and not read. But fortunately --no-cache disables the setting of cache as well, making it a possible workaround.

@lucas-benedito
Copy link

@sivel I've been able to reproduce this on my labs with Private Automation Hub 4.5.0 and ansible-galaxy 2.13.0
The same behavior does not happen with ansible-engine 2.9.27 targeting the same Private Automation Hub instance.
The error happens at exactly this point:

> /usr/lib/python3.9/site-packages/ansible/galaxy/api.py(872)get_collection_versions()
-> error_context_msg=error_context_msg, cache=True)
(Pdb) n\
> /usr/lib/python3.9/site-packages/ansible/galaxy/api.py(871)get_collection_versions()
-> data = self._call_galaxy(to_native(next_link, errors='surrogate_or_strict'),
(Pdb) n/
Calling Galaxy at https://lbenedit-ah-node1.sbransible.example.com/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/?limit=100&offset=100
n\
KeyError: '/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/'
> /usr/lib/python3.9/site-packages/ansible/galaxy/api.py(871)get_collection_versions()
-> data = self._call_galaxy(to_native(next_link, errors='surrogate_or_strict'),
(Pdb) --Return--
> /usr/lib/python3.9/site-packages/ansible/galaxy/api.py(871)get_collection_versions()->None
-> data = self._call_galaxy(to_native(next_link, errors='surrogate_or_strict'),
(Pdb) c/

the first 2 iterations are not failing:

Opened /home/devops/.ansible/galaxy_token
Calling Galaxy at https://lbenedit-ah-node1.sbransible.example.com/api/galaxy/content/community/v3/collections/community/vmware/
Calling Galaxy at https://lbenedit-ah-node1.sbransible.example.com/api/galaxy/content/community/v3/collections/community/vmware/versions/?limit=10
Calling Galaxy at https://lbenedit-ah-node1.sbransible.example.com/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/?limit=10&offset=10
[WARNING]: Skipping Galaxy server https://lbenedit-ah-node1.sbransible.example.com/api/galaxy/content/community/. Got an unexpected error when getting available versions of collection community.vmware:
'/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/'
ERROR! Unexpected Exception, this is probably a bug: '/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/'

@sivel
Copy link
Member

sivel commented Jun 8, 2022

This might be a little painful to fix, as we're likely going to have to rewrite the caching to not consolidate paginated requests under the initial path, and instead of short circuiting, we'll have to just keep all url + query string caches, and return those. Which also may change how cache invalidation is handled, since we don't have an easy way to nuke all URL caches for a collection, since they aren't very predictable.

I'm not specifically working on this issue, just trying to provide info for the engineer that does end up working on this.

@sivel
Copy link
Member

sivel commented Jun 8, 2022

Another option is we have to inspect the next link, and keep a record of the original link and the next so that we can lookup the original based on a paginated URL.

@sivel
Copy link
Member

sivel commented Jun 8, 2022

I don't know if this is a viable solution in the end, but does require the least number of changes potentially to the caching mechanism:

Patch...

diff --git a/lib/ansible/galaxy/api.py b/lib/ansible/galaxy/api.py
index 55434f6d94..3935b188d3 100644
--- a/lib/ansible/galaxy/api.py
+++ b/lib/ansible/galaxy/api.py
@@ -329,25 +329,27 @@ class GalaxyAPI:
         should_retry_error=is_rate_limit_exception
     )
     def _call_galaxy(self, url, args=None, headers=None, method=None, auth_required=False, error_context_msg=None,
-                     cache=False):
+                     cache=False, cache_key=None):
         url_info = urlparse(url)
         cache_id = get_cache_id(url)
+        if not cache_key:
+            cache_key = url_info.path
         query = parse_qs(url_info.query)
         if cache and self._cache:
             server_cache = self._cache.setdefault(cache_id, {})
             iso_datetime_format = '%Y-%m-%dT%H:%M:%SZ'
 
             valid = False
-            if url_info.path in server_cache:
-                expires = datetime.datetime.strptime(server_cache[url_info.path]['expires'], iso_datetime_format)
+            if cache_key in server_cache:
+                expires = datetime.datetime.strptime(server_cache[cache_key]['expires'], iso_datetime_format)
                 valid = datetime.datetime.utcnow() < expires
 
             is_paginated_url = 'page' in query or 'offset' in query
             if valid and not is_paginated_url:
                 # Got a hit on the cache and we aren't getting a paginated response
-                path_cache = server_cache[url_info.path]
+                path_cache = server_cache[cache_key]
                 if path_cache.get('paginated'):
-                    if '/v3/' in url_info.path:
+                    if '/v3/' in cache_key:
                         res = {'links': {'next': None}}
                     else:
                         res = {'next': None}
@@ -367,7 +369,7 @@ class GalaxyAPI:
                 # The cache entry had expired or does not exist, start a new blank entry to be filled later.
                 expires = datetime.datetime.utcnow()
                 expires += datetime.timedelta(days=1)
-                server_cache[url_info.path] = {
+                server_cache[cache_key] = {
                     'expires': expires.strftime(iso_datetime_format),
                     'paginated': False,
                 }
@@ -392,7 +394,7 @@ class GalaxyAPI:
                                % (resp.url, to_native(resp_data)))
 
         if cache and self._cache:
-            path_cache = self._cache[cache_id][url_info.path]
+            path_cache = self._cache[cache_id][cache_key]
 
             # v3 can return data or results for paginated results. Scan the result so we can determine what to cache.
             paginated_key = None
@@ -807,6 +809,7 @@ class GalaxyAPI:
         page_size_name = 'limit' if 'v3' in self.available_api_versions else 'page_size'
         versions_url = _urljoin(self.api_server, api_path, 'collections', namespace, name, 'versions', '/?%s=%d' % (page_size_name, COLLECTION_PAGE_SIZE))
         versions_url_info = urlparse(versions_url)
+        cache_key = versions_url_info.path
 
         # We should only rely on the cache if the collection has not changed. This may slow things down but it ensures
         # we are not waiting a day before finding any new collections that have been published.
@@ -826,7 +829,7 @@ class GalaxyAPI:
             if cached_modified_date != modified_date:
                 modified_cache['%s.%s' % (namespace, name)] = modified_date
                 if versions_url_info.path in server_cache:
-                    del server_cache[versions_url_info.path]
+                    del server_cache[cache_key]
 
                 self._set_cache()
 
@@ -834,7 +837,7 @@ class GalaxyAPI:
                             % (namespace, name, self.name, self.api_server)
 
         try:
-            data = self._call_galaxy(versions_url, error_context_msg=error_context_msg, cache=True)
+            data = self._call_galaxy(versions_url, error_context_msg=error_context_msg, cache=True, cache_key=cache_key)
         except GalaxyError as err:
             if err.http_code != 404:
                 raise
@@ -868,7 +871,7 @@ class GalaxyAPI:
                 next_link = versions_url.replace(versions_url_info.path, next_link)
 
             data = self._call_galaxy(to_native(next_link, errors='surrogate_or_strict'),
-                                     error_context_msg=error_context_msg, cache=True)
+                                     error_context_msg=error_context_msg, cache=True, cache_key=cache_key)
         self._set_cache()
 
         return versions

@sagarlutade
Copy link

sagarlutade commented Jun 14, 2022

@sivel I am also able to reproduce the issue with Ansible Automation Platform Controller 4.1.2 and Automation Hub 4.5.0 Operator based. Project sync from Controller.

[WARNING]: Skipping Galaxy server https://pah-example.com/api/galaxy/content/community/. Got an unexpected error when getting available versions of collection community.vmware: &apos;/api/galaxy/content/community/v3/plugin/ansible/content/comm unity/collections/index/community/vmware/versions/&apos; ERROR! Unexpected Exception, this is probably a bug: &apos;/api/galaxy/content/community/v3/plugin/ansible/content/community/collections/index/community/vmware/versions/&apos;

collections:

  • name: community.vmware
    version: '>= 2.0.0'

Setting the specific version and syncing the collection using requirements.yml fix the issue.

@ansibot
Copy link
Contributor

ansibot commented Jun 23, 2022

@watsonb This issue is waiting for your response. Please respond or the issue will be closed.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Jul 9, 2022

@watsonb You have not responded to information requests in this issue so we will assume it no longer affects you. If you are still interested in this, please create a new issue with the requested information.

click here for bot help

@ansibot ansibot closed this as completed Jul 9, 2022
@ansible ansible locked and limited conversation to collaborators Jul 16, 2022
@s-hertel
Copy link
Contributor

!needs_info

@s-hertel s-hertel reopened this Jul 21, 2022
@ansibot ansibot removed the needs_info This issue requires further information. Please answer any outstanding questions. label Jul 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. P3 Priority 3 - Approved, No Time Limitation support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants