Retry also on certain connection errors. (#680)

pull/682/head
Felix Fontein 2023-12-04 21:34:51 +01:00 committed by GitHub
parent 29cd0b3bde
commit e4ba0861e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -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)."

View File

@ -55,7 +55,8 @@ else:
IPADDRESS_IMPORT_ERROR = None 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): def _decode_retry(module, response, info, retry_count):

View File

@ -100,6 +100,8 @@ class ACMEProtocolException(ModuleFailException):
http_code=format_http_status(code), problem_code=content_json['status']) http_code=format_http_status(code), problem_code=content_json['status'])
else: else:
code = 'status {problem_code}'.format(problem_code=format_http_status(code)) 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) subproblems = content_json.pop('subproblems', None)
add_msg = ' {problem}.'.format(problem=format_error_problem(content_json)) add_msg = ' {problem}.'.format(problem=format_error_problem(content_json))
extras['problem'] = content_json extras['problem'] = content_json
@ -114,6 +116,8 @@ class ACMEProtocolException(ModuleFailException):
) )
else: else:
code = 'HTTP status {code}'.format(code=format_http_status(code)) 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: if content_json is not None:
add_msg = ' The JSON error result: {content}'.format(content=content_json) add_msg = ' The JSON error result: {content}'.format(content=content_json)
elif content is not None: elif content is not None: