You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:39:27 UTC

[buildstream] 01/02: _remote: resolve hostname before sending to grpc

This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch abderrahim/resolve-remotes
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit c7c38d73fd8e433eb61b602f826282ec41e78bf6
Author: Abderrahim Kitouni <ak...@gnome.org>
AuthorDate: Sun Mar 22 11:24:19 2020 +0100

    _remote: resolve hostname before sending to grpc
    
    grpc uses ares to resolve hostnames, which doesn't support all the nss modules
    the user may have configured
---
 src/buildstream/_remote.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/buildstream/_remote.py b/src/buildstream/_remote.py
index d01b13b..02686b9 100644
--- a/src/buildstream/_remote.py
+++ b/src/buildstream/_remote.py
@@ -17,6 +17,7 @@
 
 import os
 from collections import namedtuple
+from socket import gethostbyname
 from urllib.parse import urlparse
 
 import grpc
@@ -157,9 +158,11 @@ class BaseRemote:
 
         # Set up the communcation channel
         url = urlparse(self.spec.url)
+        host = gethostbyname(url.hostname)
+
         if url.scheme == "http":
             port = url.port or 80
-            self.channel = grpc.insecure_channel("{}:{}".format(url.hostname, port))
+            self.channel = grpc.insecure_channel("{}:{}".format(host, port))
         elif url.scheme == "https":
             port = url.port or 443
             try:
@@ -174,7 +177,7 @@ class BaseRemote:
             credentials = grpc.ssl_channel_credentials(
                 root_certificates=self.server_cert, private_key=self.client_key, certificate_chain=self.client_cert
             )
-            self.channel = grpc.secure_channel("{}:{}".format(url.hostname, port), credentials)
+            self.channel = grpc.secure_channel("{}:{}".format(host, port), credentials)
         else:
             raise RemoteError("Unsupported URL: {}".format(self.spec.url))