Skip to content

Commit

Permalink
grains/core: ignore HOST_NOT_FOUND errno in fqdns()
Browse files Browse the repository at this point in the history
Also ignore NO_DATA errors, as this imply an empty field

Fixes saltstack#52788

(cherry picked from commit 816ee23bb11a5bca3930f8e98166f498b5bcee33)
  • Loading branch information
aplanas committed Aug 29, 2019
1 parent 1ded865 commit 926b9db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def linux_distribution(**kwargs):

_INTERFACES = {}

# Possible value for h_errno defined in netdb.h
HOST_NOT_FOUND = 1
NO_DATA = 4


def _windows_cpudata():
'''
Expand Down Expand Up @@ -2233,7 +2237,7 @@ def fqdns():
name, aliaslist, addresslist = socket.gethostbyaddr(ip)
fqdns.update([socket.getfqdn(name)] + [als for als in aliaslist if salt.utils.network.is_fqdn(als)])
except socket.herror as err:
if err.errno == 0:
if err.errno in (0, HOST_NOT_FOUND, NO_DATA):
# No FQDN for this IP address, so we don't need to know this all the time.
log.debug("Unable to resolve address %s: %s", ip, err)
else:
Expand Down

0 comments on commit 926b9db

Please sign in to comment.