jupyter-rsession-proxy icon indicating copy to clipboard operation
jupyter-rsession-proxy copied to clipboard

open rstudio session for multi-user in jupyterhub

Open ssssssophia opened this issue 6 years ago • 8 comments
trafficstars

Whether it is possible to open multi rstudio sessions in a multi-user jupyterhub environment with the Jupyter-rsession-proxy extension? I have already installed the Jupyter-rsession-proxy and could open rstudio session for one user. But when I switch to another user, the rstudio session didn't work. It showed 500 : Internal Server Error, the error was could not start rstudio in time. Could anyone help me with that?

ssssssophia avatar Mar 31 '19 10:03 ssssssophia

If the user sessions are not containerized and can run on the same node, multiple rserver processes will conflict since they expect to own the same directory in /tmp/. The second rserver process fails because it cannot write to the directory in /tmp/ that is owned by the first user.

One workaround is to namespace /tmp/ using something like pam_namespace. Your spawner would need to be PAM-aware.

ryanlovett avatar Apr 01 '19 20:04 ryanlovett

@ryanlovett how to do this exactly? Or what workarounds are available at the moment to enable multi-user rstudio?

wmaroy avatar Dec 16 '19 17:12 wmaroy

@wmaroy One way I know of is pam_namespace, as mentioned above.

ryanlovett avatar Dec 17 '19 19:12 ryanlovett

I took a different approach by modifying the setup_rstudio function in jupyter_rsession_proxy/__init__.py to spawn rserver with the --secure-cookie-key-file option with a user-specific path.

I'm happy to submit a PR if there is interest.

wil avatar Dec 18 '19 13:12 wil

@wil do you have a gist or example of what your setup_rstudio function looks like in jupyter_rsession_proxy/__init__.py for spawning rserver with --secure-cookie-key-file for multi users? I've also been trying to get this to work

elijahc avatar Feb 04 '20 18:02 elijahc

@elijahc I based it on #57 and updated it like this:

--- a.py	2020-02-05 18:02:17.000000000 +1100
+++ b.py	2020-02-05 18:02:41.000000000 +1100
@@ -58,8 +58,11 @@
             else:
                 raise FileNotFoundError('Can not find rserver in PATH')
 
+        cookie_dir = os.path.join(tempfile.gettempdir(), 'rstudio-server-{}'.format(getpass.getuser()))
+        os.makedirs(cookie_dir, mode=0o700, exist_ok=True)
         return [
             executable,
+            '--secure-cookie-key-file', os.path.join(cookie_dir, 'secure-cookie-key'),
             '--www-port=' + str(port)
         ]

wil avatar Feb 05 '20 07:02 wil

@wil Yes, it'd be great if you could submit a PR. Thanks for discovering this!

ryanlovett avatar Mar 06 '20 18:03 ryanlovett

I tried to implement this, but couldn't get it to work. The most recently rstudio-server doesn't appear to have an option for --secure-cookie-key-file. Could this be an option specific to rstudio pro?

I tried with the --launcher-token arg token identifying session launcher option but that didn't seem to work and I'm not sure if it's an equivalent setting.

s-andrews avatar Jul 08 '20 08:07 s-andrews