[bitbake-devel] bitbake: hashserv: Fix localhost sometimes resolved to a wrong IP

Submitted by Anatol Belski on Sept. 17, 2020, 2:24 p.m. | Patch ID: 176609


Message ID 20200917142448.31407-1-anbelski@linux.microsoft.com
State New
Headers show

Commit Message

Anatol Belski Sept. 17, 2020, 2:24 p.m.
From: Anatol Belski <anatol.belski@microsoft.com>

From: Anatol Belski <anbelski@linux.microsoft.com>

Using localhost for direct builds on host is fine. A case with a
misbehavior has been sighted on a Docker build. Even when the host
supports IPv6, but Docker is not configured correspondingly - some
versions of the asyncio Python module seem to misbehave and try to
use IPv6 where it's not supported in the container. This happens at
least on some Ubuntu 18.04 based containers, resolving the IP
explicitly appears to be the fix.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
 bitbake/lib/hashserv/tests.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/hashserv/tests.py b/bitbake/lib/hashserv/tests.py
index b34c436876..4566f24738 100644
--- a/bitbake/lib/hashserv/tests.py
+++ b/bitbake/lib/hashserv/tests.py
@@ -14,6 +14,7 @@  import sys
 import tempfile
 import threading
 import unittest
+import socket
 class TestHashEquivalenceServer(object):
@@ -163,4 +164,8 @@  class TestHashEquivalenceUnixServer(TestHashEquivalenceServer, unittest.TestCase
 class TestHashEquivalenceTCPServer(TestHashEquivalenceServer, unittest.TestCase):
     def get_server_addr(self):
-        return "localhost:0"
+        # Some hosts cause asyncio module to misbehave, when IPv6 is not enabled.
+        # If IPv6 is enabled, it should be safe to use localhost directly, in general
+        # case it is more reliable to resolve the IP address explicitly.
+        return socket.gethostbyname("localhost") + ":0"