Merge pull request #42140 from rallytime/bp-42097

Back-port #42097 to 2016.11
This commit is contained in:
Nicole Thomas 2017-07-06 09:11:29 -06:00 committed by GitHub
commit c8afd7a3c9

View file

@ -20,6 +20,7 @@ import re
import platform
import logging
import locale
import datetime
import salt.exceptions
__proxyenabled__ = ['*']
@ -1688,12 +1689,14 @@ def ip_fqdn():
ret[key] = []
else:
try:
start_time = datetime.datetime.utcnow()
info = socket.getaddrinfo(_fqdn, None, socket_type)
ret[key] = list(set(item[4][0] for item in info))
except socket.error:
if __opts__['__role'] == 'master':
log.warning('Unable to find IPv{0} record for "{1}" causing a 10 second timeout when rendering grains. '
'Set the dns or /etc/hosts for IPv{0} to clear this.'.format(ipv_num, _fqdn))
timediff = datetime.datetime.utcnow() - start_time
if timediff.seconds > 5 and __opts__['__role'] == 'master':
log.warning('Unable to find IPv{0} record for "{1}" causing a {2} second timeout when rendering grains. '
'Set the dns or /etc/hosts for IPv{0} to clear this.'.format(ipv_num, _fqdn, timediff))
ret[key] = []
return ret