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

limit Magpie usernames #396

Merged
merged 10 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.39.0
current_version = 1.39.1
commit = True
tag = False
tag_name = {new_version}
Expand Down Expand Up @@ -30,11 +30,11 @@ search = {current_version}
replace = {new_version}

[bumpversion:file:RELEASE.txt]
search = {current_version} 2023-11-27T17:57:33Z
search = {current_version} 2023-11-29T17:03:07Z
replace = {new_version} {utcnow:%Y-%m-%dT%H:%M:%SZ}

[bumpversion:part:releaseTime]
values = 2023-11-27T17:57:33Z
values = 2023-11-29T17:03:07Z

[bumpversion:file(version):birdhouse/config/canarie-api/docker_configuration.py.template]
search = 'version': '{current_version}'
Expand Down
15 changes: 15 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@

[//]: # (list changes here, using '-' for each new entry, remove this when items are added)

[1.39.1](https://github.com/bird-house/birdhouse-deploy/tree/1.39.1) (2023-11-29)
------------------------------------------------------------------------------------------------------------------

## Changes

- Limit usernames in Magpie to match restrictions by Jupyterhub's Dockerspawner

When Jupyterhub spawns a new jupyterlab container, it escapes any non-ascii, non-digit character in the username.
This results in a username that may not match the expected username (as defined by Magpie). This mismatch results in
the container failing to spawn since expected volumes cannot be mounted to the jupyterlab container.

This fixes the issue by ensuring that juptyerhub does not convert the username that is receives from Magpie.

Note that this updates the Magpie version.

[1.39.0](https://github.com/bird-house/birdhouse-deploy/tree/1.39.0) (2023-11-27)
------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generic variables
override SHELL := bash
override APP_NAME := birdhouse-deploy
override APP_VERSION := 1.39.0
override APP_VERSION := 1.39.1

# utility to remove comments after value of an option variable
override clean_opt = $(shell echo "$(1)" | $(_SED) -r -e "s/[ '$'\t'']+$$//g")
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ for a full-fledged production platform.
* - releases
- | |latest-version| |commits-since|

.. |commits-since| image:: https://img.shields.io/github/commits-since/bird-house/birdhouse-deploy/1.39.0.svg
.. |commits-since| image:: https://img.shields.io/github/commits-since/bird-house/birdhouse-deploy/1.39.1.svg
:alt: Commits since latest release
:target: https://github.com/bird-house/birdhouse-deploy/compare/1.39.0...master
:target: https://github.com/bird-house/birdhouse-deploy/compare/1.39.1...master

.. |latest-version| image:: https://img.shields.io/badge/tag-1.39.0-blue.svg?style=flat
.. |latest-version| image:: https://img.shields.io/badge/tag-1.39.1-blue.svg?style=flat
:alt: Latest Tag
:target: https://github.com/bird-house/birdhouse-deploy/tree/1.39.0
:target: https://github.com/bird-house/birdhouse-deploy/tree/1.39.1

.. |readthedocs| image:: https://readthedocs.org/projects/birdhouse-deploy/badge/?version=latest
:alt: ReadTheDocs Build Status (latest version)
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.39.0 2023-11-27T17:57:33Z
1.39.1 2023-11-29T17:03:07Z
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ SERVICES = {
# NOTE:
# Below version and release time auto-managed by 'make VERSION=x.y.z bump'.
# Do NOT modify it manually. See 'Tagging policy' in 'birdhouse/README.rst'.
'version': '1.39.0',
'releaseTime': '2023-11-27T17:57:33Z',
'version': '1.39.1',
'releaseTime': '2023-11-29T17:03:07Z',
'institution': 'Ouranos',
'researchSubject': 'Climatology',
'supportEmail': '${SUPPORT_EMAIL}',
Expand Down Expand Up @@ -142,8 +142,8 @@ PLATFORMS = {
# NOTE:
# Below version and release time auto-managed by 'make VERSION=x.y.z bump'.
# Do NOT modify it manually. See 'Tagging policy' in 'birdhouse/README.rst'.
'version': '1.39.0',
'releaseTime': '2023-11-27T17:57:33Z',
'version': '1.39.1',
'releaseTime': '2023-11-29T17:03:07Z',
'institution': 'Ouranos',
'researchSubject': 'Climatology',
'supportEmail': '${SUPPORT_EMAIL}',
Expand Down
9 changes: 9 additions & 0 deletions birdhouse/config/jupyterhub/jupyterhub_config.py.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ c.JupyterHub.db_url = '/persist/jupyterhub.sqlite'
c.JupyterHub.template_paths = ['/custom_templates']

class CustomDockerSpawner(DockerSpawner):
@property
def escaped_name(self):
"""
Return the username without escaping. This ensures that mounted directories on the
host machine are discovered properly since we expect the username to match the username
set by Magpie.
"""
return self.user.name
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I am not sure I want to override escape_name(). This will make {username} for old existing username that potentially can have invalid char actually use the raw username with invalid char.

MAGPIE_USER_NAME_EXTRA_REGEX take effect on new username only. Existing ones, if they are invalid, are still invalid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any user who would have that issue will not be able to spawn a jupyterlab server right now and you would know about it already.

If we don't override escape_name then we have to limit the usernames to lowercase ascii and digits. I believe that @fmigneault is still not in favour of that strategy though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The Jupyter usernames were always bounded by Magpie usernames at least. The only mismatch this escape caused was about lower/upper case (which won't even be a thing anymore with an upcoming Magpie PR), and .-_ characters.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Any user who would have that issue will not be able to spawn a jupyterlab server right now and you would know about it already.

Agreed. For existing user that never log into Jupyter before, if they generate an error, hopefully they will contact us and we'll create them a new username that is "valid".

Now that I think about it though, isn't overriding escape_name() to return self.user.name the same as simply using {raw_username}? Why overriding when we can simply use {raw_username}?


async def start(self):
if(os.environ['MOUNT_IMAGE_SPECIFIC_NOTEBOOKS'] == 'true'):
host_dir = join(os.environ['JUPYTERHUB_USER_DATA_DIR'], 'tutorial-notebooks-specific-images')
Expand Down
2 changes: 1 addition & 1 deletion birdhouse/config/magpie/default.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# are applied and must be added to the list of DELAYED_EVAL.

# Tag version that will be used to update Magpie API, Magpie CLI, and matching Twitcher with Magpie Adapter
export MAGPIE_VERSION=3.36.0
export MAGPIE_VERSION=3.38.0

export MAGPIE_DB_NAME="magpiedb"

Expand Down
5 changes: 5 additions & 0 deletions birdhouse/config/magpie/magpie.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ magpie.smtp_port = ${MAGPIE_SMTP_PORT}
magpie.smtp_ssl = ${MAGPIE_SMTP_SSL}
magpie.smtp_password = ${MAGPIE_SMTP_PASSWORD}

# See https://pavics-magpie.readthedocs.io/en/latest/configuration.html#envvar-MAGPIE_USER_NAME_EXTRA_REGEX for details
# User names must match the regular expression defined here as well (whether this variable is set or not):
# https://github.com/Ouranosinc/Magpie/blob/595602/magpie/api/management/user/user_utils.py#L66
#magpie.user_name_extra_regex =

# Caching settings for specific sections/functions - improves performance response times of recurring requests
# See Twitcher INI configuration for caching that takes effect when resolving access enforcement to actual services.
# Following cache settings apply only during Magpie API requests.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
# built documents.
#
# The short X.Y version.
version = '1.39.0'
version = '1.39.1'
# The full version, including alpha/beta/rc tags.
release = '1.39.0'
release = '1.39.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down