Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work/fix firewall for localhost #8868

Merged
merged 13 commits into from
Sep 12, 2024
3 changes: 3 additions & 0 deletions distributed/deploy/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class LocalCluster(SpecCluster):
'localhost:8787' or '0.0.0.0:8787'. Defaults to ':8787'.
Set to ``None`` to disable the dashboard.
Use ':0' for a random port.
When using ':8787' the dashboard will bind to the given interface from parameter "host".
If "host" is empty, binding will occur on all interfaces '0.0.0.0'.
To avoid firewall issues when deploying locally specify "host" parameter to localhost.
maldag marked this conversation as resolved.
Show resolved Hide resolved
worker_dashboard_address: str
Address on which to listen for the Bokeh worker diagnostics server like
'localhost:8787' or '0.0.0.0:8787'. Defaults to None which disables the dashboard.
Expand Down
9 changes: 7 additions & 2 deletions distributed/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,14 @@ def start_http_server(
self.http_server = HTTPServer(self.http_application, ssl_options=ssl_options)

http_addresses = clean_dashboard_address(dashboard_address or default_port)

for http_address in http_addresses:
if http_address["address"] is None:
# Handle default case for dashboard address
# In case dashboard_address is given, e.g. ":8787"
# the address is empty and it is intended to listen to all interfaces
if dashboard_address is not None and http_address["address"] == "":
http_address["address"] = "0.0.0.0"

if http_address["address"] is None or http_address["address"] == "":
address = self._start_address
if isinstance(address, (list, tuple)):
address = address[0]
Expand Down
2 changes: 1 addition & 1 deletion distributed/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ async def test_scheduler_file():
@pytest.mark.parametrize(
"dashboard_address,expect",
[
(None, ("::", "0.0.0.0")),
(None, ("::", "0.0.0.0", "127.0.0.1")),
("127.0.0.1:0", ("127.0.0.1",)),
],
)
Expand Down
2 changes: 1 addition & 1 deletion distributed/tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ async def test_service_hosts_match_worker(s):

async with Worker(s.address, host="tcp://127.0.0.1") as w:
sock = first(w.http_server._sockets.values())
assert sock.getsockname()[0] in ("::", "0.0.0.0")
assert sock.getsockname()[0] in ("::", "127.0.0.1")

# See what happens with e.g. `dask worker --listen-address tcp://:8811`
async with Worker(s.address, host="") as w:
Expand Down
Loading