-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add compatibility prompt and notes for shared group mounting #2739
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d0c6ca9
add compatibility prompt and notes for shared group mounting
viniciusdc e45e585
update upgrade message & default prompt to no
viniciusdc 329e902
fix failing ci test
viniciusdc 984a012
add review suggestions
viniciusdc e6203d5
update unit test exception
viniciusdc 75f06bf
Merge branch 'develop' into 2736-upgrade-prompt-shared-groups
viniciusdc 61dae66
leave note for logging out users
viniciusdc 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 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
This file contains 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 |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
from typing_extensions import override | ||
|
||
from _nebari.config import backup_configuration | ||
from _nebari.keycloak import get_keycloak_admin | ||
from _nebari.stages.infrastructure import ( | ||
provider_enum_default_node_groups_map, | ||
provider_enum_name_map, | ||
|
@@ -1235,6 +1236,81 @@ def _version_specific_upgrade( | |
) | ||
rich.print("") | ||
|
||
rich.print("\n ⚠️ Upgrade Warning ⚠️") | ||
|
||
text = textwrap.dedent( | ||
""" | ||
Nebari version [green]2024.9.1[/green] introduces changes to how group | ||
directories are mounted in JupyterLab pods, now only groups with specific | ||
permissions will have their directories mounted. | ||
|
||
You will be asked to confirm how Nebari should handle your groups. | ||
No data will be lost during this operation. You can reverse this at any time | ||
by adding or removing the `allow-group-directory-creation-role` from your | ||
groups in the Keycloak UI. | ||
|
||
|
||
For more information, please see the [green][link=https://www.nebari.dev/docs/how-tos/group-directory-creation]documentation[/link][/green]. | ||
""" | ||
) | ||
rich.print(text) | ||
|
||
confirm = Prompt.ask( | ||
"[bold]Would you like Nebari to update your group permissions now?[/bold]", | ||
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. If we are clear with what the feature is actually doing in the intro text, then I think we can change this to: Would you like Nebari to assign |
||
choices=["y", "N"], | ||
default="N", | ||
) | ||
if confirm.lower() == "y": | ||
# Proceed with updating group permissions | ||
keycloak_admin = get_keycloak_admin( | ||
server_url=f"https://{config['domain']}/auth/", | ||
username="root", | ||
password=config["security"]["keycloak"]["initial_root_password"], | ||
) | ||
client_id = keycloak_admin.get_client_id("jupyterhub") | ||
_role_representation = keycloak_admin.get_role_by_id( | ||
role_id=keycloak_admin.get_client_role_id( | ||
client_id=client_id, role_name="allow-group-directory-creation-role" | ||
) | ||
) | ||
groups = keycloak_admin.get_groups() | ||
groups_with_roles = keycloak_admin.get_client_role_groups( | ||
client_id=client_id, role_name="allow-group-directory-creation-role" | ||
) | ||
groups_without_role = [ | ||
group | ||
for group in groups | ||
if group["id"] not in [group["id"] for group in groups_with_roles] | ||
] | ||
|
||
if groups_without_role: | ||
group_names = ", ".join( | ||
[group["name"] for group in groups_without_role] | ||
) | ||
rich.print( | ||
f"\n[bold]Updating the following groups with the required permissions:[/bold] {group_names}\n" | ||
) | ||
for group in groups_without_role: | ||
_group_id = group["id"] | ||
keycloak_admin.assign_group_client_roles( | ||
group_id=_group_id, | ||
client_id=client_id, | ||
roles=[_role_representation], | ||
) | ||
rich.print( | ||
"[green]Group permissions have been updated successfully.[/green]" | ||
) | ||
else: | ||
rich.print( | ||
"\n[green]All groups already have the required permissions.[/green]\n" | ||
) | ||
else: | ||
rich.print( | ||
"\n[bold yellow]You have chosen not to update group permissions at this time.[/bold yellow]" | ||
) | ||
rich.print( | ||
"You can update them later by visiting the Keycloak UI and adding or removing the `allow-group-directory-creation-role` from your groups.\n" | ||
) | ||
return config | ||
|
||
|
||
|
This file contains 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
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.
I think this could use a little more detail explaining exactly what's going on here and specifying that the two options here are either all groups or just admin/analyst/developer. Suggested rewording below (please review for accuracy as well as grammar!)
Nebari version [green]2024.9.1[/green] introduces changes to how group directories are mounted in JupyterLab pods.
In previous versions of Nebari, every Keycloak group in the Nebari realm initiated the creation of a shared file directory that all group members could access in their JupyterLab pod at
~/shared/[group-name]
.As of Nebari version [green]2024.9.1[/green], only groups that are assigned the
jupyterhub
Client Roleallow-group-directory-creation
willYou will be asked to confirm whether Nebari should now assign this role to all of your current groups. If not, only the
admin
,analyst
, anddeveloper
group directories will be mounted in JupyterHub pods.Regardless of your choice now, no data will be lost during this operation. You can re-mount group directories at any time by adding or removing the
allow-group-directory-creation-role
from your groups in the Keycloak UI.For more information, please see the [green][link=https://www.nebari.dev/docs/how-tos/group-directory-creation]documentation[/link][/green].