При перезапуске несоответствие прав доступа к домашней папке пользователя Jupyterhub - PullRequest
0 голосов
/ 31 октября 2019

Я установил один сервер с Google Auth Jupyterhub, используя Docker. Вы можете найти сценарии установки здесь - https://github.com/deepakputhraya/jupyterhub. Настройка хорошо работает с несколькими пользователями, которые могут войти в систему с отдельными домашними каталогами.

Проблема возникает, когда я обновляю файл Dockerfile или needs.txt и перезагружаю сервер. Пользователи, чьи учетные записи созданы, могут войти в систему, но не могут получить доступ к своим домашним папкам.

[ec2-user@ip-10-0-1-196 ~]$ sudo docker exec -it jupyterhub /bin/sh
# ls -lah /home
total 64K
drwxr-xr-x 16 root      root      4.0K Oct 18 10:17 .
drwxr-xr-x  1 root      root      4.0K Sep  4 15:46 ..
drwxr-xr-x 15 abhilash  abhilash  4.0K Oct 31 10:51 abhilash
drwxr-xr-x  9 ajay      ajay      4.0K Oct 10 09:11 ajay
drwxr-xr-x  8 abhilash  abhilash  4.0K Sep  2 11:05 akshay
drwxr-xr-x  7 deepak    deepak    4.0K Oct  4 12:20 deepak

Журналы:

[I 2019-10-31 14:57:14.985 JupyterHub log:174] 200 GET /hub/spawn-pending/deepak (deepak@127.0.0.1) 38.35ms
[I 2019-10-31 14:57:17.321 JupyterHub spawner:1387] Spawning jupyterhub-singleuser --port=34405 --NotebookApp.default_url=/lab
Traceback (most recent call last):
  File "/opt/conda/lib/python3.6/site-packages/traitlets/traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'runtime_dir'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/bin/jupyterhub-singleuser", line 10, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.6/site-packages/jupyterhub/singleuser.py", line 660, in main
    return SingleUserNotebookApp.launch_instance(argv)
  File "/opt/conda/lib/python3.6/site-packages/jupyter_core/application.py", line 268, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "/opt/conda/lib/python3.6/site-packages/jupyterhub/singleuser.py", line 558, in initialize
    return super().initialize(argv)
  File "</opt/conda/lib/python3.6/site-packages/decorator.py:decorator-gen-7>", line 2, in initialize
  File "/opt/conda/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/notebook/notebookapp.py", line 1676, in initialize
    self.init_configurables()
  File "/opt/conda/lib/python3.6/site-packages/notebook/notebookapp.py", line 1349, in init_configurables
    connection_dir=self.runtime_dir,
  File "/opt/conda/lib/python3.6/site-packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/opt/conda/lib/python3.6/site-packages/traitlets/traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "/opt/conda/lib/python3.6/site-packages/jupyter_core/application.py", line 99, in _runtime_dir_default
    ensure_dir_exists(rd, mode=0o700)
  File "/opt/conda/lib/python3.6/site-packages/jupyter_core/utils/__init__.py", line 13, in ensure_dir_exists
    os.makedirs(path, mode=mode)
  File "/opt/conda/lib/python3.6/os.py", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  File "/opt/conda/lib/python3.6/os.py", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  File "/opt/conda/lib/python3.6/os.py", line 210, in makedirs
    makedirs(head, mode, exist_ok)
  [Previous line repeated 1 more time]
  File "/opt/conda/lib/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/home/deepak'
[I 2019-10-31 14:57:18.274 JupyterHub log:174] 302 GET /hub/spawn/deepak -> /hub/spawn-pending/deepak (deepak@127.0.0.1) 1014.98ms
[I 2019-10-31 14:57:18.332 JupyterHub pages:303] deepak is pending spawn
[I 2019-10-31 14:57:18.335 JupyterHub log:174] 200 GET /hub/spawn-pending/deepak (deepak@127.0.0.1) 17.16ms
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<BaseHandler.spawn_single_user() done, defined at /opt/conda/lib/python3.6/site-packages/jupyterhub/handlers/base.py:697> exception=HTTPError()>
Traceback (most recent call last):
  File "/opt/conda/lib/python3.6/site-packages/jupyterhub/handlers/base.py", line 889, in spawn_single_user
    timedelta(seconds=self.slow_spawn_timeout), finish_spawn_future
tornado.util.TimeoutError: Timeout

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.6/site-packages/jupyterhub/handlers/base.py", line 922, in spawn_single_user
    % (status, spawner._log_name),
tornado.web.HTTPError: HTTP 500: Internal Server Error (Spawner failed to start [status=1]. The logs for deepak may contain details.)
[W 2019-10-31 14:57:44.492 JupyterHub user:678] deepak's server never showed up at http://127.0.0.1:34405/user/deepak/ after 30 seconds. Giving up
[E 2019-10-31 14:57:44.530 JupyterHub gen:593] Exception in Future <Task finished coro=<BaseHandler.spawn_single_user.<locals>.finish_user_spawn() done, defined at /opt/conda/lib/python3.6/site-packages/jupyterhub/handlers/base.py:800> exception=TimeoutError("Server at http://127.0.0.1:34405/user/deepak/ didn't respond in 30 seconds",)> after timeout
    Traceback (most recent call last):
      File "/opt/conda/lib/python3.6/site-packages/tornado/gen.py", line 589, in error_callback
        future.result()
      File "/opt/conda/lib/python3.6/site-packages/jupyterhub/handlers/base.py", line 807, in finish_user_spawn
        await spawn_future
      File "/opt/conda/lib/python3.6/site-packages/jupyterhub/user.py", line 654, in spawn
        await self._wait_up(spawner)
      File "/opt/conda/lib/python3.6/site-packages/jupyterhub/user.py", line 701, in _wait_up
        raise e
      File "/opt/conda/lib/python3.6/site-packages/jupyterhub/user.py", line 669, in _wait_up
        http=True, timeout=spawner.http_timeout, ssl_context=ssl_context
      File "/opt/conda/lib/python3.6/site-packages/jupyterhub/utils.py", line 234, in wait_for_http_server
        timeout=timeout,
      File "/opt/conda/lib/python3.6/site-packages/jupyterhub/utils.py", line 177, in exponential_backoff
        raise TimeoutError(fail_message)
    TimeoutError: Server at http://127.0.0.1:34405/user/deepak/ didn't respond in 30 seconds

Разрешения для папки для пользователя akshay соответствуют abhilash. Новые пользователи, которые регистрируются впервые, не имеют этой проблемы. Опять же, это происходит только при обновлении образа Docker. Если бы я перезапустил сервер, это не решило бы проблему и не изменило карту разрешений для папок пользователя для других пользователей.

Почему разрешения не совпадают? Как это можно исправить?

...