Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

Molecule tests fail when Galaxy API returns 500 errors or KeyError: 'results' during collection installation. This happens intermittently due to Galaxy server overload.

Changes

  • ansible.cfg: Configure 180s timeout for Galaxy API requests (default is 60s)
  • Molecule action: Wrap molecule test with retry logic (3 attempts, 30s delay between attempts)

The retry logic in .github/actions/molecule/action.yaml:

MAX_RETRIES=3
RETRY_DELAY=30
ATTEMPT=1

while [ $ATTEMPT -le $MAX_RETRIES ]; do
  echo "Attempt $ATTEMPT of $MAX_RETRIES..."
  
  if sudo --preserve-env=... molecule test -s ${{ inputs.scenario }}; then
    exit 0
  fi
  
  EXIT_CODE=$?
  if [ $ATTEMPT -lt $MAX_RETRIES ]; then
    echo "Retrying in ${RETRY_DELAY}s..."
    sleep $RETRY_DELAY
    ATTEMPT=$((ATTEMPT + 1))
  else
    exit $EXIT_CODE
  fi
done

This handles transient API failures without masking legitimate errors.

Original prompt

This section details on the original issue you should resolve

<issue_title>Jobs often fail with Galaxy giving 500s</issue_title>
<issue_description>This is a failure that can happen early:

Run sudo --preserve-env=ANSIBLE_PYTHON_INTERPRETER,ATMOSPHERE_NETWORK_BACKEND,MOLECULE_CSI_DRIVER env "PATH=$PATH" molecule test -s aio
WARNING  Molecule scenarios should migrate to 'extensions/molecule'
INFO     [aio > discovery] scenario test matrix: dependency, cleanup, destroy, syntax, create, prepare, converge, idempotence, side_effect, verify, cleanup, destroy
INFO     [aio > prerun] Performing prerun with role_name_check=0...
WARNING  Retrying execution failure 250 of: ansible-galaxy collection install -vvv community.crypto:2.2.3
ERROR    Command ansible-galaxy collection install -vvv community.crypto:2.2.3, returned 250 code:
Starting galaxy collection install process
Process install dependency map
the full traceback was:

Traceback (most recent call last):
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/cli/__init__.py", line 658, in cli_executor
    exit_code = cli.run()
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/cli/galaxy.py", line 773, in run
    return context.CLIARGS()
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/cli/galaxy.py", line 120, in method_wrapper
    return wrapped_method(*args, **kwargs)
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/cli/galaxy.py", line 1438, in execute_install
    self._execute_install_collection(
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/cli/galaxy.py", line 1487, in _execute_install_collection
    install_collections(
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/galaxy/collection/__init__.py", line 735, in install_collections
    dependency_map = _resolve_depenency_map(
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/galaxy/collection/__init__.py", line 1852, in _resolve_depenency_map
    return collection_dep_resolver.resolve(
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/resolvelib/resolvers.py", line 397, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/resolvelib/resolvers.py", line 148, in _add_to_criteria
    matches = self._p.find_matches(
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/galaxy/dependency_resolution/providers.py", line 477, in find_matches
    match for match in self._find_matches(list(requirements))
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/galaxy/dependency_resolution/providers.py", line 253, in _find_matches
    coll_versions =  if preinstalled_candidates else self._api_proxy.get_collection_versions(first_req)  # type: t.Iterable]
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 106, in get_collection_versions
    return set(
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 106, in <genexpr>
    return set(
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 87, in _get_collection_versions
    raise last_error
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 66, in _get_collection_versions
    versions = api.get_collection_versions(requirement.namespace, requirement.name)
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/galaxy/api.py", line 145, in wrapped
    return method(self, *args, **kwargs)
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/atmosphere/.venv/lib/python3.10/site-packages/ansible/galaxy/api.py", line 874, in get_collection_versions
    data = self._call_galaxy(versions_url, error_context_msg=error_context_msg, cache=True, cache_key=cache_key)
  File "/opt/github/actions-runner/2.330.0/_work/atmosphere/...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes vexxhost/atmosphere#3582

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/vexxhost/atmosphere/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 9, 2026 03:08
Co-authored-by: mnaser <435815+mnaser@users.noreply.github.com>
Co-authored-by: mnaser <435815+mnaser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix jobs failing with Galaxy 500 errors feat: add retry logic for transient Galaxy API failures Feb 9, 2026
Copilot AI requested a review from mnaser February 9, 2026 03:11
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