Skip to content

Commit

Permalink
Merge "Retry Ansible Galaxy calls"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Dec 19, 2024
2 parents d9e13e7 + 638e1e3 commit 9bdcb55
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
25 changes: 19 additions & 6 deletions kolla_ansible/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import yaml

from importlib.metadata import Distribution
from time import sleep

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -106,12 +107,24 @@ def galaxy_collection_install(requirements_file: str,
args += ["--requirements-file", requirements_file]
if force:
args += ["--force"]
try:
run_command("ansible-galaxy", args)
except subprocess.CalledProcessError as e:
LOG.error("Failed to install Ansible collections from %s via Ansible "
"Galaxy: returncode %d", requirements_file, e.returncode)
sys.exit(e.returncode)

for retry_count in range(1, 6):
try:
run_command("ansible-galaxy", args)
except subprocess.CalledProcessError as e:
if retry_count < 5:
LOG.warning(f"Failed to install Ansible collections from "
f"{requirements_file} using Ansible Galaxy "
f"(error: {e}) (retry: {retry_count}/5)")
sleep(2)
continue
else:
LOG.error(f"Failed to install Ansible collections from "
f"{requirements_file} using Ansible Galaxy "
f"(error: {e}) after 5 retries")
LOG.error("Exiting")
sys.exit(e.returncode)
break


def read_file(path: os.path, mode: str = "r") -> str | bytes:
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/install-deps-retries-fbe2a3abb41abb6d.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
features:
- |
``kolla-ansible install-deps`` subcommand will now retry on Ansible Galaxy
collections installation failures.

0 comments on commit 9bdcb55

Please sign in to comment.