Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spurious warnings when using docker run --user=X #1546

Merged
merged 4 commits into from
Dec 15, 2021

Conversation

maresb
Copy link
Contributor

@maresb maresb commented Dec 11, 2021

Closes #1520

During tests, I now check for unexpected ERROR/WARNING messages.

I added a few tests to check for expected warning messages regarding

  • unable to write to /etc/passwd because uid != 0
  • unable to write to /home/jovyan because user not in users(100) group

I also improved the warning messages to suggest solutions in both cases.

To suppress the spurious warnings from #1520, I warn only when the defaults change, which is in-line with the old logic.

I removed the "test for nonempty" tests -n "${NB_USER}", -n "${NB_UID}", -n "${NB_GID}", because these variables all have nonempty default values, so they should never be empty in the first place.

Finally, if the user goes through the trouble of setting it, I allow the jovyan user to be replaced in /etc/passwd with ${NB_USER} instead of just jovyan, because we can.

@mathbunnyru
Copy link
Member

@maresb could you please merge latest master to your branch?

@maresb maresb force-pushed the fix-spurious-warning branch from 812420b to 8958ba7 Compare December 14, 2021 20:12
@maresb
Copy link
Contributor Author

maresb commented Dec 14, 2021

@mathbunnyru, sure! 😄

Copy link
Member

@mathbunnyru mathbunnyru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work, thanks @maresb!

base-notebook/test/test_container_options.py Show resolved Hide resolved
base-notebook/test/test_container_options.py Show resolved Hide resolved
@mathbunnyru
Copy link
Member

I think this is a great change, merging this one.

@mathbunnyru mathbunnyru merged commit 985bd82 into jupyter:master Dec 15, 2021
@maresb maresb deleted the fix-spurious-warning branch December 15, 2021 10:46
tlvu added a commit to Ouranosinc/PAVICS-e2e-workflow-tests that referenced this pull request Dec 21, 2021
The reason why the old startup CMD was hanging was because the new script
assumed user jovyan exists in the docker image.  The script was using
"set -e" so any errors just make the script exit immediately.

So we rollback before this commit jupyter/docker-stacks@c772e98.
The commit was part of this PR jupyter/docker-stacks#1546.

Error with the new script: it just stops there:
```
(birdy) jenkins@e4c447185b3b:/$ /usr/local/bin/start-notebook.sh
+ set -e
+ [[ -n '' ]]
+ wrapper=
+ [[ '' == \y\e\s ]]
+ [[ -n '' ]]
+ echo 'WARNING: Jupyter Notebook deprecation notice https://github.com/jupyter/docker-stacks#jupyter-notebook-deprecation-notice.'
WARNING: Jupyter Notebook deprecation notice https://github.com/jupyter/docker-stacks#jupyter-notebook-deprecation-notice.
+ exec /usr/local/bin/start.sh jupyter notebook
+ set -e
+ _log 'Entered start.sh with args:' jupyter notebook
+ [[ Entered start.sh with args: jupyter notebook == \E\R\R\O\R\:* ]]
+ [[ Entered start.sh with args: jupyter notebook == \W\A\R\N\I\N\G\:* ]]
+ [[ '' == '' ]]
+ echo 'Entered start.sh with args:' jupyter notebook
Entered start.sh with args: jupyter notebook
+ '[' 2 -eq 0 ']'
+ cmd=("$@")
+ run-hooks /usr/local/bin/start-notebook.d
+ [[ ! -d /usr/local/bin/start-notebook.d ]]
+ return
++ id -u
+ '[' 1000 == 0 ']'
+ [[ '' == \1 ]]
+ [[ '' == \y\e\s ]]
++ id -u jovyan
+ JOVYAN_UID=
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed write to /etc/passwd
2 participants