Properly log address that failed to resolve or pass connection check

This commit is contained in:
Ivan Babrou 2017-02-09 17:12:04 -08:00
parent 9a34fbeba9
commit af9578631e
No known key found for this signature in database
GPG Key ID: DBF6C142408CB4F0
2 changed files with 7 additions and 7 deletions

View File

@ -154,8 +154,8 @@ def resolve_dns(opts, fallback=True):
if opts['retry_dns']: if opts['retry_dns']:
while True: while True:
import salt.log import salt.log
msg = ('Master hostname: \'{0}\' not found. Retrying in {1} ' msg = ('Master hostname: \'{0}\' not found or not responsive. '
'seconds').format(opts['master'], opts['retry_dns']) 'Retrying in {1} seconds').format(opts['master'], opts['retry_dns'])
if salt.log.setup.is_console_configured(): if salt.log.setup.is_console_configured():
log.error(msg) log.error(msg)
else: else:

View File

@ -733,7 +733,7 @@ def dns_check(addr, port, safe=False, ipv6=None):
if not hostnames: if not hostnames:
error = True error = True
else: else:
addr = False resolved = False
for h in hostnames: for h in hostnames:
if h[0] == socket.AF_INET and ipv6 is True: if h[0] == socket.AF_INET and ipv6 is True:
continue continue
@ -747,11 +747,11 @@ def dns_check(addr, port, safe=False, ipv6=None):
s.connect((candidate_addr.strip('[]'), port)) s.connect((candidate_addr.strip('[]'), port))
s.close() s.close()
addr = candidate_addr resolved = candidate_addr
break break
except Exception: except Exception:
pass pass
if not addr: if not resolved:
error = True error = True
except TypeError: except TypeError:
err = ('Attempt to resolve address \'{0}\' failed. Invalid or unresolveable address').format(addr) err = ('Attempt to resolve address \'{0}\' failed. Invalid or unresolveable address').format(addr)
@ -760,7 +760,7 @@ def dns_check(addr, port, safe=False, ipv6=None):
error = True error = True
if error: if error:
err = ('DNS lookup of \'{0}\' failed.').format(addr) err = ('DNS lookup or connection check of \'{0}\' failed.').format(addr)
if safe: if safe:
if salt.log.is_console_configured(): if salt.log.is_console_configured():
# If logging is not configured it also means that either # If logging is not configured it also means that either
@ -769,7 +769,7 @@ def dns_check(addr, port, safe=False, ipv6=None):
log.error(err) log.error(err)
raise SaltClientError() raise SaltClientError()
raise SaltSystemExit(code=42, msg=err) raise SaltSystemExit(code=42, msg=err)
return addr return resolved
def required_module_list(docstring=None): def required_module_list(docstring=None):