Skip to content

Commit

Permalink
Retry also on certain connection errors. (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein authored Dec 4, 2023
1 parent 29cd0b3 commit e4ba086
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/680-acme-retry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "acme_* modules - also retry requests in case of socket errors, bad status lines, and unknown connection errors; improve error messages in these cases (https://github.com/ansible-collections/community.crypto/issues/680)."
3 changes: 2 additions & 1 deletion plugins/module_utils/acme/acme.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
IPADDRESS_IMPORT_ERROR = None


RETRY_STATUS_CODES = (408, 429, 503)
# -1 usually means connection problems
RETRY_STATUS_CODES = (-1, 408, 429, 503)


def _decode_retry(module, response, info, retry_count):
Expand Down
4 changes: 4 additions & 0 deletions plugins/module_utils/acme/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def __init__(self, module, msg=None, info=None, response=None, content=None, con
http_code=format_http_status(code), problem_code=content_json['status'])
else:
code = 'status {problem_code}'.format(problem_code=format_http_status(code))
if code == -1 and info.get('msg'):
code += ' ({msg})'.format(msg=info['msg'])
subproblems = content_json.pop('subproblems', None)
add_msg = ' {problem}.'.format(problem=format_error_problem(content_json))
extras['problem'] = content_json
Expand All @@ -114,6 +116,8 @@ def __init__(self, module, msg=None, info=None, response=None, content=None, con
)
else:
code = 'HTTP status {code}'.format(code=format_http_status(code))
if code == -1 and info.get('msg'):
code += ' ({msg})'.format(msg=info['msg'])
if content_json is not None:
add_msg = ' The JSON error result: {content}'.format(content=content_json)
elif content is not None:
Expand Down

0 comments on commit e4ba086

Please sign in to comment.