Skip to content

Commit

Permalink
limit Magpie usernames (#396)
Browse files Browse the repository at this point in the history
## Overview

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 mounter to the jupyterlab container.

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


## Changes

**Non-breaking changes**
- limits usernames in Magpie

**Breaking changes**
- If any users currently exist with invalid usernames, an admin needs to
update their user name in Magpie

## Related Issue / Discussion

- Resolves #393

## Additional Information

<!--
The test suite can be run using a different DACCS config with
``birdhouse_daccs_configs_branch: branch_name`` in the PR description.
To globally skip the test suite regardless of the commit message use
``birdhouse_skip_ci: true`` in the PR description.
-->

birdhouse_daccs_configs_branch: master
birdhouse_skip_ci: false
  • Loading branch information
mishaschwartz authored Nov 29, 2023
2 parents 44d217f + 3e4ca0e commit 02e22fb
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 16 deletions.
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
8 changes: 4 additions & 4 deletions birdhouse/config/canarie-api/docker_configuration.py.template
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

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

0 comments on commit 02e22fb

Please sign in to comment.