mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
commit
f5cef6395e
2 changed files with 10 additions and 1 deletions
|
@ -2434,7 +2434,7 @@ def ip_fqdn():
|
|||
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:
|
||||
except (socket.error, UnicodeError):
|
||||
timediff = datetime.datetime.utcnow() - start_time
|
||||
if timediff.seconds > 5 and __opts__["__role"] == "master":
|
||||
log.warning(
|
||||
|
|
|
@ -667,6 +667,15 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
|
|||
}
|
||||
self._run_os_grains_tests("debian-9", _os_release_map, expectation)
|
||||
|
||||
def test_unicode_error(self):
|
||||
raise_unicode_mock = MagicMock(
|
||||
name="raise_unicode_error", side_effect=UnicodeError
|
||||
)
|
||||
with patch("salt.grains.core.hostname"):
|
||||
with patch("socket.getaddrinfo", raise_unicode_mock):
|
||||
ret = salt.grains.core.ip_fqdn()
|
||||
assert ret["fqdn_ip4"] == ret["fqdn_ip6"] == []
|
||||
|
||||
@skipIf(not salt.utils.platform.is_linux(), "System is not Linux")
|
||||
def test_ubuntu_xenial_os_grains(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue