summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSviatoslav Sydorenko <wk@sydorenko.org.ua>2022-08-30 19:01:23 +0200
committerGitHub <noreply@github.com>2022-08-30 12:01:23 -0500
commitb1c73fa870d26fb14841b3c477c028aaaeadd01e (patch)
tree680c9fb4aeb8a0c7d961892ab238a212b0762494
parent6e070b90cae99528f606c4c3a681bff8005f6d77 (diff)
downloadansible-b1c73fa870d26fb14841b3c477c028aaaeadd01e.tar.gz
Fail fast in stuck `ansible-galaxy-collection` (#78629)
This specific integration test gets stuck periodically causing the Galaxy jobs to be killed on timeout wasting an hour of runtime. The module that gets stuck waiting on Pulp is an in-test one, called `setup_collections`. When it works, the task is complete in around 70 seconds but when it doesn't, it just freezes the whole play. This patch attempts to make it fail faster by putting a reasonable timeout value of 2 minutes. (cherry picked from commit f1c56e988dbbb769b34a3c80baa40c916b4d0c88)
-rw-r--r--test/integration/targets/ansible-galaxy-collection/library/setup_collections.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py b/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py
index 6f1a17f971..9f2ee53085 100644
--- a/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py
+++ b/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py
@@ -85,6 +85,10 @@ from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_bytes
from functools import partial
from multiprocessing import dummy as threading
+from multiprocessing import TimeoutError
+
+
+COLLECTIONS_BUILD_AND_PUBLISH_TIMEOUT = 120
def publish_collection(module, collection):
@@ -182,7 +186,14 @@ def run_module():
pool = threading.Pool(4)
publish_func = partial(publish_collection, module)
- result['results'] = pool.map(publish_func, module.params['collections'])
+ try:
+ result['results'] = pool.map_async(
+ publish_func, module.params['collections'],
+ ).get(timeout=COLLECTIONS_BUILD_AND_PUBLISH_TIMEOUT)
+ except TimeoutError as timeout_err:
+ module.fail_json(
+ 'Timed out waiting for collections to be provisioned.',
+ )
failed = bool(sum(
r['build']['rc'] + r['publish']['rc'] for r in result['results']