Skip to content

Commit

Permalink
Use a getaddrinfo resolvable hostname as the local hostname (will b…
Browse files Browse the repository at this point in the history
…e used as the etcd endpoint further). (#2006)


Signed-off-by: Tao He <linzhu.ht@alibaba-inc.com>
  • Loading branch information
sighingnow committed Sep 5, 2022
1 parent be07087 commit 6dff1dc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion coordinator/gscoordinator/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,15 @@ def _launch_etcd(self):
else:
self._etcd_peer_port = get_free_port()
if len(self._hosts) > 1:
try:
local_hostname = socket.gethostname()
socket.gethostbyname(
local_hostname
) # make sure the hostname is dns-resolvable
except Exception:
local_hostname = "127.0.0.1" # fallback to a must-correct hostname
self._etcd_endpoint = "http://{0}:{1}".format(
socket.gethostname(), str(self._etcd_client_port)
local_hostname, str(self._etcd_client_port)
)
else:
self._etcd_endpoint = "http://127.0.0.1:{0}".format(
Expand Down

0 comments on commit 6dff1dc

Please sign in to comment.