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

Changes required for Jupyter-Scheduler integration #1832

Merged
merged 17 commits into from
Jul 20, 2023

Conversation

iameskild
Copy link
Member

@iameskild iameskild commented Jun 13, 2023

Reference Issues or PRs

Closes #1755

This PR makes several modifications that are required for Jupyter-Scheduler to work with Nebari, specifically the Argo-Workflows extension that I built. A few additional changes were also required on the Nebari-Workflow-Controller side; see PR 16.

The main changes include:

  • Renaming jupyter_notebook_config to jupyter_server_config and enabling jupyter_server.serverapp.ServerApp on JupyterHub - these changes are required for Jupyter Scheduler to work with our current version of JupyterHub.
  • Mounting the ARGO_TOKEN specific to the group the user is in (admin, developer or viewer) which means that only users with Argo admin and developer roles will be allowed to submit jobs.
  • Mounting a view-only conda-store API token that is used to validate which conda-store environments/kernels are useable.

What does this implement/fix?

Put a x in the boxes that apply

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds a feature)
  • Breaking change (fix or feature that would cause existing features not to work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Other (please describe):

Testing

  • Did you test the pull request locally?
  • Did you add new tests?

Any other comments?

@iameskild iameskild requested a review from Adam-D-Lewis June 13, 2023 13:06
@iameskild iameskild added the needs: documentation 📖 This item is missing docs label Jun 13, 2023
@pavithraes
Copy link
Member

pavithraes commented Jun 13, 2023

We need some people to test this out, before including it in a release.

@iameskild iameskild added this to the Release 2023.7.1 milestone Jun 27, 2023
conda-store-environments = var.conda-store-environments
default-conda-store-namespace = var.conda-store-default-namespace
conda-store-cdsdashboard-token = module.kubernetes-conda-store-server.service-tokens.cdsdashboards
conda-store-argo-workflows-jupyter-scheduler-token = module.kubernetes-conda-store-server.service-tokens.argo-workflows-jupyter-scheduler
Copy link
Member

Choose a reason for hiding this comment

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

passing token so it can be set on jupyter user pods?

Copy link
Member

Choose a reason for hiding this comment

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

Is jupyter scheduler a pod that runs?

Copy link
Member Author

@iameskild iameskild Jul 11, 2023

Choose a reason for hiding this comment

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

Jupyter-Scheduler is a lab extension that runs while the user pod is running. Getting access to view the conda-store makes it so we can more reliably set the path for the conda-store environments (mostly for this function).

The conda-store feature is also a traitlet, albeit just a basic toggle.

Comment on lines 319 to 332
ADMIN = "admin"
DEVELOPER = "developer"
ANALYST = "analyst"

base = "argo-"

if ANALYST in groups:
argo_sa = base + "view"
if DEVELOPER in groups:
argo_sa = base + "dev"
if ADMIN in groups:
argo_sa = base + "admin"
else:
return {}
Copy link
Member

@Adam-D-Lewis Adam-D-Lewis Jul 4, 2023

Choose a reason for hiding this comment

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

This seems a bit clunky, plus we might get rid of analyst, dev, and admin. Not sure if there's a better way. Maybe check the individual argo permissions of the groups themselves.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree! The difficult part is that roles aren't available in the current spawner.user.auth_state. I think the other alternative is to perform a keycloak API call. We would probably also need to add keycloak secrets to the hub deployment.

I have this particular enhancement in this issue.

"ARGO_TOKEN": {
"valueFrom": {
"secretKeyRef": {
"name": f"{argo_sa}.service-account-token",
Copy link
Member

Choose a reason for hiding this comment

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

Did the modifications you made create this token or did it already exist?

Copy link
Member Author

Choose a reason for hiding this comment

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

This token already exists, it's the default argo-admin, argo-dev and argo-view secrets. I'm not entirely sure if they were being used prior to this... The ARGO_TOKEN used when someone creates a workflow from the UI (and the one that can be copied from there) are not the same as any of those above.

I have also included this the enhancements issue, namely, the ability to create short-lived tokens on a per user basis.


def profile_conda_store_viewer_token():
return {
"CONDA_STORE_TOKEN": {
Copy link
Member

Choose a reason for hiding this comment

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

Any way this token could be misused by the user? It's used by ARGO_WORKFLOWS_EXECUTOR, I see - https://github.com/search?q=repo%3Anebari-dev%2Fargo-workflows-executor+CONDA_STORE_TOKEN&type=code

Copy link
Member

Choose a reason for hiding this comment

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

Is Argo Workflows Executor a package that's installable or a pod that's running or its included on the jupyterhub pod?

Copy link
Member Author

Choose a reason for hiding this comment

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

This token is view-only in scope so if the user was motivated enough, they could view all of the namespaces/environments that exist.

Copy link
Member

Choose a reason for hiding this comment

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

Later down the road we should scope this token to just what the user can see. But for now this works.


data = {
"conda-store-api-token" = var.conda-store-argo-workflows-jupyter-scheduler-token
"conda-store-service-name" = var.conda-store-service-name
Copy link
Member

Choose a reason for hiding this comment

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

This is a url I guess. I want to double check this later and make sure there's not a better way.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah this is an internal service url. conda-store-service-name, as a variable name, is used elsewhere in the other services so I just kept the same name.

@iameskild iameskild requested a review from Adam-D-Lewis July 17, 2023 16:14
Copy link
Member

@costrouc costrouc left a comment

Choose a reason for hiding this comment

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

Nothing controversial here to me. I like the changes. @iameskild and @Adam-D-Lewis has this PR been tested with a deployment?


def profile_conda_store_viewer_token():
return {
"CONDA_STORE_TOKEN": {
Copy link
Member

Choose a reason for hiding this comment

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

Later down the road we should scope this token to just what the user can see. But for now this works.

@iameskild iameskild merged commit 46f7c24 into develop Jul 20, 2023
@iameskild iameskild deleted the jupyter_scheduler_changes branch July 20, 2023 16:59
costrouc added a commit that referenced this pull request Aug 3, 2023
@costrouc costrouc mentioned this pull request Aug 3, 2023
27 tasks
iameskild pushed a commit that referenced this pull request Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

Look into Jupyter Scheduler for possible integration into Nebari
4 participants