Skip to content

Commit

Permalink
Fix worker dashboard proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
milesgranger committed Feb 26, 2024
1 parent 9bdb381 commit 0874a9b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions distributed/http/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ def initialize(self, dask_server=None, extra=None):
self.scheduler = dask_server
self.extra = extra or {}

# `get_current_user` and `prepare` method impls reference
# issue in tornado & jupyter server compat here
# https://github.com/jupyter-server/jupyter_server/issues/1012
def get_current_user(self):
return "dask"

Check warning on line 26 in distributed/http/proxy.py

View check run for this annotation

Codecov / codecov/patch

distributed/http/proxy.py#L25-L26

Added lines #L25 - L26 were not covered by tests

async def prepare(self):
web.authenticated(lambda rq: None)(self)

Check warning on line 29 in distributed/http/proxy.py

View check run for this annotation

Codecov / codecov/patch

distributed/http/proxy.py#L28-L29

Added lines #L28 - L29 were not covered by tests

async def http_get(self, port, host, proxied_path):
# route here first
# incoming URI /proxy/{port}/{host}/{proxied_path}
Expand All @@ -29,6 +38,9 @@ async def http_get(self, port, host, proxied_path):
uri = f"/proxy/{port}/{proxied_path}"
self.request.uri = uri

if self.host not in self.host_allowlist:
self.host_allowlist.append(self.host)

Check warning on line 42 in distributed/http/proxy.py

View check run for this annotation

Codecov / codecov/patch

distributed/http/proxy.py#L41-L42

Added lines #L41 - L42 were not covered by tests

# slash is removed during regex in handler
proxied_path = "/%s" % proxied_path

Expand All @@ -41,6 +53,8 @@ async def http_get(self, port, host, proxied_path):
return await self.proxy(port, proxied_path)

async def open(self, port, host, proxied_path):
if host not in self.host_allowlist:
self.host_allowlist.append(host)

Check warning on line 57 in distributed/http/proxy.py

View check run for this annotation

Codecov / codecov/patch

distributed/http/proxy.py#L56-L57

Added lines #L56 - L57 were not covered by tests
# finally, proxy to other address/port
return await self.proxy_open(host, port, proxied_path)

Expand Down

0 comments on commit 0874a9b

Please sign in to comment.