-
Notifications
You must be signed in to change notification settings - Fork 108
support updated kubespawner #2938
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e709f09
support updated kubespawner
Adam-D-Lewis b7e19fc
Merge branch 'main' into update_kubespawner
dcmcand 85c6321
Merge branch 'main' into update_kubespawner
dcmcand 1d9821c
Merge branch 'main' into update_kubespawner
Adam-D-Lewis 5829038
add new default_image so we can test the PR
Adam-D-Lewis be4781b
Merge branch 'main' into update_kubespawner
Adam-D-Lewis 93b7112
Revert "add new default_image so we can test the PR"
Adam-D-Lewis 30f0c5d
Merge branch 'main' into update_kubespawner
Adam-D-Lewis 1051be1
Reapply "add new default_image so we can test the PR"
Adam-D-Lewis 4d2e89a
fix profile options issue when not specified
Adam-D-Lewis b153dac
Revert "Reapply "add new default_image so we can test the PR""
Adam-D-Lewis ffc77d6
fix SyntaxWarning where we failed to escape a backslash
Adam-D-Lewis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
| from pathlib import Path | ||
|
|
||
| import z2jh | ||
| from tornado import gen | ||
|
|
||
|
|
||
| def base_profile_home_mounts(username): | ||
|
|
@@ -512,7 +511,6 @@ def render_profile( | |
| return None | ||
|
|
||
| profile = copy.copy(profile) | ||
| profile_kubespawner_override = profile.get("kubespawner_override") | ||
| profile["kubespawner_override"] = functools.reduce( | ||
| deep_merge, | ||
| [ | ||
|
|
@@ -522,38 +520,27 @@ def render_profile( | |
| base_profile_extra_mounts(), | ||
| configure_user(username, groups), | ||
| configure_user_provisioned_repositories(username), | ||
| profile_kubespawner_override, | ||
| profile.get("kubespawner_override"), | ||
| ], | ||
| {}, | ||
| ) | ||
|
|
||
| # We need to merge any env vars from the spawner with any overrides from the profile | ||
| # This is mainly to ensure JUPYTERHUB_ANYONE/GROUP is passed through from the spawner | ||
| # to control dashboard access. | ||
| envvars_fixed = {**(profile["kubespawner_override"].get("environment", {}))} | ||
|
|
||
| def preserve_envvars(spawner): | ||
| # This adds in JUPYTERHUB_ANYONE/GROUP rather than overwrite all env vars, | ||
| # if set in the spawner for a dashboard to control access. | ||
| return { | ||
| **envvars_fixed, | ||
| **spawner.environment, | ||
| profile["kubespawner_override"]["environment"].update( | ||
| { | ||
| **profile_argo_token(groups), | ||
| **profile_conda_store_viewer_token(), | ||
| } | ||
|
|
||
| profile["kubespawner_override"]["environment"] = preserve_envvars | ||
| ) | ||
|
|
||
| return profile | ||
|
|
||
|
|
||
| @gen.coroutine | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. flyby: tornado coroutine to native coroutine |
||
| def render_profiles(spawner): | ||
| async def render_profiles(spawner): | ||
| # jupyterhub does not yet manage groups but it will soon | ||
| # so for now we rely on auth_state from the keycloak | ||
| # userinfo request to have the groups in the key | ||
| # "auth_state.oauth_user.groups" | ||
| auth_state = yield spawner.user.get_auth_state() | ||
| auth_state = await spawner.user.get_auth_state() | ||
|
|
||
| username = auth_state["oauth_user"]["preferred_username"] | ||
|
|
||
|
|
@@ -570,7 +557,7 @@ def render_profiles(spawner): | |
|
|
||
| # fetch available profiles and render additional attributes | ||
| profile_list = z2jh.get_config("custom.profiles") | ||
| return list( | ||
| rendered_profiles = list( | ||
| filter( | ||
| None, | ||
| [ | ||
|
|
@@ -585,6 +572,7 @@ def render_profiles(spawner): | |
| ], | ||
| ) | ||
| ) | ||
| return rendered_profiles | ||
|
|
||
|
|
||
| c.KubeSpawner.args = ["--debug"] | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior of Kubespawner changed in v5 so kubespawner_override's default behavior is merge instead of replace now so I'm now simplifing this part.
reference: https://jupyterhub-kubespawner.readthedocs.io/en/latest/changelog.html#id24