diff options
author | Luke Meyer <lmeyer@redhat.com> | 2017-08-22 17:26:16 -0400 |
---|---|---|
committer | Luke Meyer <lmeyer@redhat.com> | 2017-09-13 14:56:55 -0400 |
commit | b24e7bfc86894d7c9d81cb5600d7d7b1981844c0 (patch) | |
tree | cd8480a70687c0988a9709617c14b622ee78ceaf /roles/lib_utils/library | |
parent | 665c5c2058b989a58a99022be198e9c7a6383a1a (diff) | |
download | openshift-b24e7bfc86894d7c9d81cb5600d7d7b1981844c0.tar.gz openshift-b24e7bfc86894d7c9d81cb5600d7d7b1981844c0.tar.bz2 openshift-b24e7bfc86894d7c9d81cb5600d7d7b1981844c0.tar.xz openshift-b24e7bfc86894d7c9d81cb5600d7d7b1981844c0.zip |
add retries to repoquery module
Diffstat (limited to 'roles/lib_utils/library')
-rw-r--r-- | roles/lib_utils/library/repoquery.py | 18 | ||||
-rw-r--r-- | roles/lib_utils/library/yedit.py | 1 |
2 files changed, 13 insertions, 6 deletions
diff --git a/roles/lib_utils/library/repoquery.py b/roles/lib_utils/library/repoquery.py index 95a305b58..e5ac1f74f 100644 --- a/roles/lib_utils/library/repoquery.py +++ b/roles/lib_utils/library/repoquery.py @@ -35,6 +35,7 @@ import os # noqa: F401 import re # noqa: F401 import shutil # noqa: F401 import tempfile # noqa: F401 +import time # noqa: F401 try: import ruamel.yaml as yaml # noqa: F401 @@ -618,17 +619,22 @@ def main(): show_duplicates=dict(default=False, required=False, type='bool'), match_version=dict(default=None, required=False, type='str'), ignore_excluders=dict(default=False, required=False, type='bool'), + retries=dict(default=4, required=False, type='int'), + retry_interval=dict(default=5, required=False, type='int'), ), supports_check_mode=False, required_if=[('show_duplicates', True, ['name'])], ) - rval = Repoquery.run_ansible(module.params, module.check_mode) - - if 'failed' in rval: - module.fail_json(**rval) - - module.exit_json(**rval) + tries = 1 + while True: + rval = Repoquery.run_ansible(module.params, module.check_mode) + if 'failed' not in rval: + module.exit_json(**rval) + elif tries > module.params['retries']: + module.fail_json(**rval) + tries += 1 + time.sleep(module.params['retry_interval']) if __name__ == "__main__": diff --git a/roles/lib_utils/library/yedit.py b/roles/lib_utils/library/yedit.py index baf72fe47..921bca074 100644 --- a/roles/lib_utils/library/yedit.py +++ b/roles/lib_utils/library/yedit.py @@ -35,6 +35,7 @@ import os # noqa: F401 import re # noqa: F401 import shutil # noqa: F401 import tempfile # noqa: F401 +import time # noqa: F401 try: import ruamel.yaml as yaml # noqa: F401 |