Skip to content

How should users configure distributed.dashboard.link? #7736

Open

Description

@mplough-kobold

The distributed.dashboard.link setting is often used when using Dask from JupyterHub so that the dashboard can be served via the Jupyter Server Proxy with no additional network configuration. #7724 was triggered by a distributed.dashboard.link / DASK_DISTRIBUTED__DASHBOARD__LINK (see docs) setting that contains environment variables that are set on the host but not on the cluster.

Settings like this would trigger the issue:

export DASK_DISTRIBUTED__DASHBOARD__LINK="{JUPYTERHUB_EXTERNAL_BASE_URL}{JUPYTERHUB_SERVICE_PREFIX}proxy/{port}/status"
export DASK_DISTRIBUTED__DASHBOARD__LINK="{JUPYTERHUB_SERVICE_PREFIX}proxy/{port}/status"

Recommended settings did not trigger the issue:

# from https://github.com/dask/dask-labextension/issues/109#issuecomment-580151835
export DASK_DISTRIBUTED__DASHBOARD__LINK="proxy/{port}/status"
# from https://docs.dask.org/en/stable/configuration.html#environment-variables
export DASK_DISTRIBUTED__DASHBOARD__LINK="/user/<user>/proxy/8787/status"

However, these recommended settings are problematic.

The first, proxy/{port}/status, produces an incorrect link. Suppose I have a JupyterHub deployment and I access my notebook server at:

https://jupyterhub.example.com/user/matt.plough/my-named-server/lab

Using proxy/{port}/status results in the browser creating the following link in the output of a cell that says client:

https://jupyterhub.example.com/user/matt.plough/my-named-server/files/proxy/8787/status?_xsrf=[some token]

This is incorrect due to the inclusion of /files, something that does not occur when JUPYTERHUB_SERVICE_PREFIX is part of the DASK_DISTRIBUTED__DASHBOARD__LINK variable.

The second, /user/<user>/proxy/8787/status, cannot accommodate named servers and is not flexible enough to deal with standard servers and named servers on the same box. Use of the JUPYTERHUB_SERVICE_PREFIX environment variable eliminates all of these problems.

How should users configure the DASK_DISTRIBUTED__DASHBOARD__LINK variable when using a JupyterHub proxy?

Activity

  1. jabbera commented on Mar 31, 2023

    @jabbera

    TLDR: IMO, when using the SSHCluster the scheduler dashboard should be port forwarded from the ssh target running the scheduler to the machine that's creating the cluster. The dashboard link configuration variable is only guaranteed to be correct there. It looses all context once you SSH to another node.

    The long version:

    I don't know if there is a correct answer to this question.

    When we are using the dask locally the environment variables above are correct.

    Using the ssh cluster the correct setting for the dashboard link is whatever is correct for the first server passed into the node list since that is your scheduler node.

    This node may or may not even be a jupyterhub node. In our case we enable ssh endpoints on all of our jupyterhub nodes so things like vscode and pycharm work properly if you don't like the native notebook interface. This makes using the SSHCluster easy. That said a user could certainly use any ssh target which may not be a jupyterhub node making the environment variable not appropriate.

    What if you were tunneling through a jump server for your SSHCluster and you don't have direct network access to the scheduler node from your current python environment? There is no setting for that environment variable that makes sense in this case.

    Naively I would think setting up a port forward from the scheduler node to the host you are creating the cluster from would be the way to ensure that the scheduler dashboard was available. Then the environment variable would be correct since it's relative to the machine you are creating the cluster from as opposed to where the scheduler is running (which again, may be unrelated to the environment you are creating the cluster from). asyncssh makes this easy but I don't want to pretend I've thought this through for more then 2 minutes.

    Our end solution to this issue was to put all of our environment variables at the top of the bashrc so they are loaded into the ssh session created by asyncssh and the scheduler stopped crashing.

    This won't work for everyone or every use case though.

  2. jacobtomlinson commented on Apr 3, 2023

    @jacobtomlinson
    Member

    I think the setting you want for JupyterHub + SSHCluster is

    export DASK_DISTRIBUTED__DASHBOARD__LINK="{JUPYTERHUB_EXTERNAL_BASE_URL}{JUPYTERHUB_SERVICE_PREFIX}proxy/{host}:{port}/status"

    Note the inclusion of the {host}: so that things are forwarded to the correct node. This will require a little extra config in jupyter-server-proxy as accessing arbitrary nodes presents a small security risk, but it sounds like you're doing that anyway. https://jupyter-server-proxy.readthedocs.io/en/latest/arbitrary-ports-hosts.html

    This currently will trigger the bug which we are tracking in #7724 and should be fixed shortly.

  3. jabbera commented on Apr 3, 2023

    @jabbera

    @jacobtomlinson I still don't think that works if you are using an ssh cluster that's unrelated to your jupyterhub environment and might be network segmented. IE using a cluster that might be accessed like this from the command line: ssh -J myjumphost target_node. That said, I have a solution that works fine for me and am happy with whatever you decide as the official recommendation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions