jupyterhub / nbgitpuller

Jupyter server extension to sync a git repository one-way to a local path
https://nbgitpuller.readthedocs.io
BSD 3-Clause "New" or "Revised" License
212 stars 86 forks source link

login failure if student renames the nbgitpuller target file and instructor pushes an unrelated new file #221

Closed trevorcampbell closed 2 years ago

trevorcampbell commented 3 years ago

Bug description

Roughly:

Then nbgitpuller fails to log in with exit status 128.

Expected behaviour

nbgitpuller should pull a fresh copy of worksheet_02.ipynb from the repo and bring the student to that file. nbgitpuller should also successfully pull the new, unrelated file other_file.txt.

Actual behaviour

nbgitpuller fails to log in (and the student is no longer able to log in until the instructor manually addresses the issue in the server backend).

How to reproduce

Setup:

  1. Create a public repository at https://github.com/ubc-dsci/test-repo-2 with 4 files:
    • file1.txt
    • file2.txt
    • README.md
    • worksheet_02.ipynb these files can have anything in them, I don't think the contents matter. I imagine that there is a simpler version of the repo in which the issue still occurs, but this is what I used.
  2. Create a Canvas assignment with an nbgitpuller link.

Making the error occur:

  1. Click the nbgitpuller link from Canvas to open the assignment
  2. Make some edit in the assignment, and save it
  3. Close all open Jupyter browser tabs
  4. Click the nbgitpuller link again
  5. This time, inside JupyterLab, rename the worksheet_02.ipynb to something else, e.g. MAIN.ipynb
  6. Close all open Jupyter browser tabs again
  7. somewhere else (e.g. on GitHub), push a new file to the repository. In the test-repo-2 repo, I pushed test2.txt.
  8. somewhere else (e.g. on GitHub) make an edit to another unrelated file and push. I edited file1.txt.
  9. Go back to Canvas and click the nbgitpuller link again.

(I think the edit to file1.txt is likely not necessary, but that's what I did in my testing. My guess is that it's the pushed new file test2.txt that is more related to the issue.)

You will see this error scrn

Your personal set up

Server is running centos

rpm -q centos-release
centos-release-7-8.2003.0.el7.centos.x86_64

Our JHub uses DockerSpawner and LTIAuthenticator.

This is the server environment itself. The docker container environment is further down below.

pip3 freeze
alembic==1.6.5
argon2-cffi==20.1.0
async-generator==1.10
atomicwrites==1.4.0
attrs==20.1.0
backcall==0.2.0
bleach==3.1.5
certifi==2021.5.30
certipy==0.1.3
cffi==1.14.6
chardet==3.0.4
charset-normalizer==2.0.3
cryptography==3.1
decorator==4.4.2
defusedxml==0.6.0
dictauth==0.1
docker==5.0.0
dockerspawner==12.2.0.dev0
editdistance==0.5.3
entrypoints==0.3
escapism==1.0.1
gitdb==4.0.5
gitdb2==4.0.2
GitPython==3.1.8
greenlet==1.1.0
idna==3.2
importlib-metadata==4.6.1
ipykernel==5.3.4
ipython==7.16.1
ipython-genutils==0.2.0
ipywidgets==7.5.1
jedi==0.17.2
Jinja2==3.0.1
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.7
jupyter-console==6.2.0
jupyter-core==4.6.3
jupyter-telemetry==0.1.0
jupyterhub==1.4.2
jupyterhub-idle-culler==1.0
jupyterhub-ltiauthenticator==0.4.0
Mako==1.1.4
MarkupSafe==2.0.1
mistune==0.8.4
more-itertools==8.5.0
nbconvert==5.6.1
nbformat==5.0.7
nbgrader==0.5.6
notebook==6.1.3
oauthenticator==0.11.0
oauthlib==3.1.1
packaging==20.4
pamela==1.0.0
pandocfilters==1.4.2
parso==0.7.1
pendulum==2.1.2
pexpect==4.8.0
pickleshare==0.7.5
pluggy==0.6.0
prometheus-client==0.11.0
prompt-toolkit==3.0.7
ptyprocess==0.6.0
py==1.9.0
pycparser==2.20
pycurl==7.43.0.5
Pygments==2.6.1
pyOpenSSL==19.1.0
pyparsing==2.4.7
pyrsistent==0.16.0
pytest==3.6.3
python-crontab==2.3.4
python-dateutil==2.8.2
python-editor==1.0.4
python-json-logger==2.0.1
pytzdata==2020.1
pyzmq==19.0.2
qtconsole==4.7.6
QtPy==1.9.0
requests==2.26.0
ruamel.yaml==0.17.10
ruamel.yaml.clib==0.2.6
rudaux==0.1
semantic-version==2.8.5
Send2Trash==1.5.0
setuptools-rust==0.12.1
six==1.16.0
smmap==3.0.4
SQLAlchemy==1.4.22
syzygyauthenticator==0.0.8.dev0
terminado==0.8.3
terminaltables==3.1.0
testpath==0.4.4
toml==0.10.2
tornado==6.1
tqdm==4.49.0
traitlets==4.3.3
typing-extensions==3.10.0.0
urllib3==1.26.6
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.1.0
widgetsnbextension==3.5.1
zipp==3.5.0

Now inside the docker container (we are using ubcdsci/r-dsci-100:v0.28.0 with nbgitpuller==1.0.3 but I have tried to reproduce this on ubcdsci/r-dsci-100:v0.17.0 with nbgitpuller==0.9.0dev and it still happens there too):

pip3 list
Package                       Version
----------------------------- ----------
alembic                       1.7.1
anyio                         3.3.0
argon2-cffi                   20.1.0
async-generator               1.10
attrs                         21.2.0
Babel                         2.9.1
backcall                      0.2.0
backports.functools-lru-cache 1.6.4
bleach                        4.1.0
blinker                       1.4
brotlipy                      0.7.0
certifi                       2021.5.30
certipy                       0.1.3
cffi                          1.14.6
chardet                       4.0.0
charset-normalizer            2.0.0
colorama                      0.4.4
conda                         4.10.3
conda-package-handling        1.7.3
cryptography                  3.4.7
debugpy                       1.4.1
decorator                     5.1.0
defusedxml                    0.7.1
entrypoints                   0.3
gitdb                         4.0.7
GitPython                     3.1.24
greenlet                      1.1.1
idna                          3.1
importlib-metadata            4.8.1
importlib-resources           5.2.2
ipykernel                     6.4.1
ipython                       7.27.0
ipython-genutils              0.2.0
jedi                          0.18.0
Jinja2                        3.0.1
json5                         0.9.5
jsonschema                    3.2.0
jupyter-client                7.0.3
jupyter-core                  4.8.1
jupyter-server                1.11.0
jupyter-server-mathjax        0.2.3
jupyter-telemetry             0.1.0
jupyterhub                    1.4.2
jupyterlab                    3.1.12
jupyterlab-git                0.32.4
jupyterlab-pygments           0.1.2
jupyterlab-server             2.8.1
jupytext                      1.12.0
Mako                          1.1.5
mamba                         0.15.3
markdown-it-py                1.1.0
MarkupSafe                    2.0.1
matplotlib-inline             0.1.3
mdit-py-plugins               0.2.8
mistune                       0.8.4
nbclassic                     0.3.2
nbclient                      0.5.4
nbconvert                     6.1.0
nbdime                        3.1.0
nbformat                      5.1.3
nbgitpuller                   1.0.3.dev0
nest-asyncio                  1.5.1
notebook                      6.4.4
oauthlib                      3.1.1
packaging                     21.0
pamela                        1.0.0
pandocfilters                 1.5.0
parso                         0.8.2
pexpect                       4.8.0
pickleshare                   0.7.5
pip                           21.2.4
prometheus-client             0.11.0
prompt-toolkit                3.0.20
ptyprocess                    0.7.0
pycosat                       0.6.3
pycparser                     2.20
pycurl                        7.44.1
Pygments                      2.10.0
PyJWT                         2.1.0
pyOpenSSL                     20.0.1
pyparsing                     2.4.7
pyrsistent                    0.17.3
PySocks                       1.7.1
python-dateutil               2.8.2
python-json-logger            2.0.1
pytz                          2021.1
PyYAML                        5.4.1
pyzmq                         22.3.0
requests                      2.26.0
requests-unixsocket           0.2.0
ruamel.yaml                   0.17.16
ruamel.yaml.clib              0.2.2
ruamel-yaml-conda             0.15.80
Send2Trash                    1.8.0
setuptools                    58.0.4
six                           1.16.0
smmap                         4.0.0
sniffio                       1.2.0
SQLAlchemy                    1.4.23
terminado                     0.12.1
testpath                      0.5.0
toml                          0.10.2
tornado                       6.1
tqdm                          4.62.2
traitlets                     5.1.0
typing-extensions             3.10.0.2
urllib3                       1.26.6
wcwidth                       0.2.5
webencodings                  0.5.1
websocket-client              0.57.0
wheel                         0.37.0
zipp                          3.5.0

import sys

from subprocess import check_call

def create_fs_hook(spawner):
      username = spawner.user.name
      callysto_user = 'username_hidden'
      course = 'coursename_hidden'
      check_call(['/some/unproblematic/script.sh', course, username, callysto_user])

c.Spawner.pre_spawn_hook = create_fs_hook

c.JupyterHub.admin_access = False
c.JupyterHub.base_url = '/jupyter'
c.JupyterHub.confirm_no_ssl = True
c.JupyterHub.hub_ip = 'ip_address_hidden'
c.JupyterHub.ip = 'ip_address_hidden'
c.JupyterHub.services = [{'name': 'idle-culler', 'admin': True, 'command': [sys.executable, '-m', 'jupyterhub_idle_culler', '--timeout=3600']}]

c.JupyterHub.spawner_class = 'dockerspawner.DockerSpawner'
c.DockerSpawner.extra_host_config = {'mem_limit': '2g', 'memswap_limit': '2g', 'cpu_period': 100000, 'cpu_quota': 100000, 'ulimits': [{'name': 'core', 'hard': 0}] }
c.DockerSpawner.remove_containers = True
c.DockerSpawner.use_internal_ip = True
c.DockerSpawner.host_ip = '0.0.0.0'
c.DockerSpawner.image = 'ubcdsci/r-dsci-100:v0.28.0'
c.DockerSpawner.volumes = {'/path/to/storage/{username}': '/home/jupyter'}
c.DockerSpawner.post_start_cmd = 'sh -c "cp -a /tmp/user-settings/. /home/jupyter/.jupyter/lab/user-settings"'

c.Authenticator.admin_users  = set([])

c.JupyterHub.authenticator_class = 'ltiauthenticator.LTIAuthenticator'
c.LTIAuthenticator.consumers  = { os.environ['LTI_CLIENT_KEY']: os.environ['LTI_CLIENT_SECRET'] }
c.Spawner.default_url = '/lab'

welcome[bot] commented 3 years ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

trevorcampbell commented 2 years ago

As of c23461d4f7ce47ec4e0d2bcfc3b2fde4939b80f8 this is fixed; closing. I believe PRs #257 #264 #269 probably addressed this.