-
Notifications
You must be signed in to change notification settings - Fork 2
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
Enable NWC to mutate workflows created by service accounts #16
Conversation
nebari_workflow_controller/utils.py
Outdated
@@ -45,6 +48,28 @@ def sent_by_argo(workflow: dict): | |||
return None | |||
|
|||
|
|||
def valid_argo_roles(): | |||
# TODO: determine a more extensible way of generating a list of valid roles | |||
return ["argo-admin", "argo-developer"] |
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 should be a config option somehow. Most other things in Nebari use traitlets, but I'd feel okay using an VALID_ARGO_ROLES ENV var for now.
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.
Agreed, this is not a good solution. I added a configmap
to the nebari-workflow-controller deployment that provides a list of valid Argo roles (here). How does that solution work for you?
nebari_workflow_controller/utils.py
Outdated
preferred_username = workflow["metadata"]["labels"][ | ||
"workflows.argoproj.io/creator-preferred-username" | ||
] | ||
if validate_service_account(keycloak_uid): | ||
for user in kcadm.get_users(): | ||
if user["username"] == preferred_username: | ||
return user["id"], preferred_username |
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.
This won't work in some cases. You can't always go back to the actual username b/c "Labels only contain [-_.0-9a-zA-Z]", so any other characters will be turned into "-") so not a 1 to 1 mapping.
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.
That's a good catch! I realize though that this is an issue elsewhere here. I added both the sanitize_label
and desanitize_label
functions to handle grabbing usernames from k8s labels. This is how JupyterHub converts usernames with disallowed characters (although I can't find the source code for how they accomplish this).
The two places where this is most important are:
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.
see comments
Have you run the tests? Could we add a test for the new functionality? |
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.
LGTM. But like @Adam-D-Lewis mentioned it would be helpful to have tests for this worklfow.
@costrouc @Adam-D-Lewis I added new tests that cover the special case where the Workflow was created via a service-account. |
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.
@iameskild this are some detailed tests and I like the fixtures that you created in conftest.py
. Thanks! LGTM.
Since @Adam-D-Lewis is on PTO and we are trying to get a release out for nebari. I am comfortable with merging. @iameskild feel free to merge when it works best. |
Reference Issues or PRs
This PR is a related to the work being done to integrate Jupyter-Scheduler (#1832).
What does this implement/fix?
Put a
x
in the boxes that applyTesting
Documentation
Access-centered content checklist
Text styling
H1
or#
in markdown).Non-text content
Any other comments?