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:28 UTC
[buildstream] 02/02: _sandboxremote: 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 2330501ba3b81e86d4a77173542659ae8f82e25d
Author: Abderrahim Kitouni <ak...@gnome.org>
AuthorDate: Sun Mar 22 11:31:39 2020 +0100
_sandboxremote: resolve hostname before sending to grpc
---
src/buildstream/sandbox/_sandboxremote.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/buildstream/sandbox/_sandboxremote.py b/src/buildstream/sandbox/_sandboxremote.py
index 3dcbb2c..f98c934 100644
--- a/src/buildstream/sandbox/_sandboxremote.py
+++ b/src/buildstream/sandbox/_sandboxremote.py
@@ -22,6 +22,7 @@ import os
import shutil
from collections import namedtuple
from urllib.parse import urlparse
+from socket import gethostbyname
from functools import partial
import grpc
@@ -353,10 +354,13 @@ class SandboxRemote(SandboxREAPI):
"You must supply a protocol and port number in the execution-service url, "
"for example: http://buildservice:50051."
)
+
+ host = gethostbyname(url.hostname)
+
if url.scheme == "http":
- channel = grpc.insecure_channel("{}:{}".format(url.hostname, url.port))
+ channel = grpc.insecure_channel("{}:{}".format(host, url.port))
elif url.scheme == "https":
- channel = grpc.secure_channel("{}:{}".format(url.hostname, url.port), self.exec_credentials)
+ channel = grpc.secure_channel("{}:{}".format(host, url.port), self.exec_credentials)
else:
raise SandboxError(
"Remote execution currently only supports the 'http' protocol "
@@ -410,10 +414,13 @@ class SandboxRemote(SandboxREAPI):
"You must supply a protocol and port number in the action-cache-service url, "
"for example: http://buildservice:50051."
)
+
+ host = gethostbyname(url.hostname)
+
if url.scheme == "http":
- channel = grpc.insecure_channel("{}:{}".format(url.hostname, url.port))
+ channel = grpc.insecure_channel("{}:{}".format(host, url.port))
elif url.scheme == "https":
- channel = grpc.secure_channel("{}:{}".format(url.hostname, url.port), self.action_credentials)
+ channel = grpc.secure_channel("{}:{}".format(host, url.port), self.action_credentials)
with channel:
request = remote_execution_pb2.GetActionResultRequest(