jupyterhub 启动时出现错误:“KeyError:‘用户 k 不存在。’”

jupyterhub 启动时出现错误:“KeyError:‘用户 k 不存在。’”

我遇到了一个问题,jupyterhub 实际上无法启动,但它发出了一个我无法完全调试的错误。

输出自journalctl --unit=jupyterhub

Aug 04 14:04:12 rkhost jupyterhub[7145]: [I 2016-08-04 14:04:12.594 JupyterHub app:622] Loading cookie_secret from /usr/local/etc/jupyterhub/jupyterhub_cookie_secret
Aug 04 14:04:12 rkhost jupyterhub[7145]: [E 2016-08-04 14:04:12.630 JupyterHub app:1296]
Aug 04 14:04:12 rkhost jupyterhub[7145]: Traceback (most recent call last):
Aug 04 14:04:12 rkhost jupyterhub[7145]: File "/usr/local/lib/python3.4/dist-packages/jupyterhub/app.py", line 1293, in launch_instance_async
Aug 04 14:04:12 rkhost jupyterhub[7145]: yield self.initialize(argv)
Aug 04 14:04:12 rkhost jupyterhub[7145]: File "/usr/local/lib/python3.4/dist-packages/jupyterhub/app.py", line 1102, in initialize
Aug 04 14:04:12 rkhost jupyterhub[7145]: yield self.init_users()
Aug 04 14:04:12 rkhost jupyterhub[7145]: File "/usr/local/lib/python3.4/dist-packages/jupyterhub/app.py", line 803, in init_users
Aug 04 14:04:12 rkhost jupyterhub[7145]: yield gen.maybe_future(self.authenticator.add_user(user))
Aug 04 14:04:12 rkhost jupyterhub[7145]: File "/usr/local/lib/python3.4/dist-packages/jupyterhub/auth.py", line 328, in add_user
Aug 04 14:04:12 rkhost jupyterhub[7145]: raise KeyError("User %s does not exist." % user.name)
Aug 04 14:04:12 rkhost jupyterhub[7145]: KeyError: 'User k does not exist.'
Aug 04 14:04:12 rkhost systemd[1]: jupyterhub.service: main process exited, code=exited, status=1/FAILURE
Aug 04 14:04:12 rkhost systemd[1]: Unit jupyterhub.service entered failed state.

内容/usr/local/etc/jupyterhub/jupyterhub_config.py

c.Authenticator.admin_users = set(['rkern99']
c.Authenticator.whitelist = set(['rkern99'])
c.JupyterHub.admin_access = False
c.JupyterHub.answer_yes = False
c.JupyterHub.authenticator_class = 'jupyterhub.auth.PAMAuthenticator'
c.JupyterHub.base_url = '/'
c.JupyterHub.cleanup_proxy = True
c.JupyterHub.cleanup_servers = True
c.JupyterHub.config_file = '/usr/local/etc/jupyterhub/jupyterhub_config.py'
c.JupyterHub.confirm_no_ssl = True
c.JupyterHub.cookie_max_age_days = 14
c.JupyterHub.cookie_secret_file = 'jupyterhub_cookie_secret'
c.JupyterHub.data_files_path = '/usr/local/share/jupyter/hub'
c.JupyterHub.db_kwargs = {}
c.JupyterHub.hub_ip = '10.0.0.50'
c.JupyterHub.hub_port = 54321
c.JupyterHub.hub_prefix = '/hub/'
c.JupyterHub.ip = '10.0.0.50'
c.JupyterHub.port = 80
c.JupyterHub.proxy_api_ip = '10.0.0.50'
c.JupyterHub.proxy_api_port = 5432
c.JupyterHub.proxy_auth_token = '1941890e3eb3d835a754b0c09dc542f33b6616ede96376c9464770d7c205d970'
c.JupyterHub.proxy_cmd = ['configurable-http-proxy']
c.JupyterHub.spawner_class = 'sudospawner.SudoSpawner'
c.Spawner.notebook_dir = '~/Jupyter/'

内容/lib/systemd/system/jupyterhub.service

[Unit]
Description=Jupyterhub
After=network-online.target

[Service]
User=jupyterhub
ExecStart=/usr/local/bin/jupyterhub --config=/usr/local/etc/jupyterhub/jupyterhub_config.py
WorkingDirectory=/usr/local/etc/jupyterhub

[Install]
WantedBy=multi-user.target

用户和组的验证

$ grep jupyterhub /etc/passwd
jupyterhub:x:1001:1002::/var/jupyterhub:/usr/sbin/nologin
$ grep jupyterhub /etc/passwd
jupyterhub:x:1001:1002::/var/jupyterhub:/usr/sbin/nologin

这是全新安装的 Debian 8 Jessie,并且所有安装的 apt/pip/pip3/npm 包都是最新的。

答案1

由于我自己解决了这个问题,所以结果发现是 出了问题/usr/local/etc/jupyterhub/jupyterhub.sqlite。删除文件解决了问题,但我不确定为什么。我怀疑数据库是在加载错误的先前配置时创建的,并且不知何故不会覆盖。

相关内容