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

Make CDSDashboards.conda_envs dynamically update from function #1358

Merged
merged 12 commits into from
Oct 7, 2022

Conversation

costrouc
Copy link
Member

@costrouc costrouc commented Jul 5, 2022

Closes #1310
Closes #1293

Changes introduced in this PR:

  • cdsdashboards conda environments are now populated by a function. In this case the environments will be updated based on the available environments from conda-store.

Types of changes

What types of changes does your PR introduce?

Put an 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 to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Other (please describe):

Testing

Requires testing

  • Yes
  • No

In case you checked yes, did you write tests?

  • Yes
  • No

@costrouc costrouc changed the title Initial attempt to prove functions work Make CDSDashboards.conda_envs dynamically update from function Jul 5, 2022
@costrouc costrouc force-pushed the feat-use-cds-dashboard branch 2 times, most recently from bfc6bb3 to fcbde47 Compare July 5, 2022 14:02
@costrouc
Copy link
Member Author

costrouc commented Jul 5, 2022

Also related #1293

@costrouc
Copy link
Member Author

costrouc commented Aug 9, 2022

I will update this issue later today. @viniciusdc will help with testing this PR once the tests pass.

@costrouc
Copy link
Member Author

Will be working on this PR later tomorrow and have complete by Tuesday. Goal is to make use of the conda-store api to get available environments.

@trallard
Copy link
Member


Will be using the conda-store API

@costrouc
Copy link
Member Author

@HarshCasper some details on how to accomplish this.

In the conda_store_config.py we will need to generate an api token via

c.AuthenticationBackend.predefined_tokens = {
     f"{config["cdsdashboard-secret"]}": {
           "primary_namespace": "cdsdashboards",
           "role_bindings": {
                "*/*": ["viewer"],
           }
     }
}

This is passed inside of here https://github.com/Quansight/qhub/blob/main/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/conda-store/server.tf#L1-L23. The more I think about it these tokens and permissions should be passed in in https://github.com/Quansight/qhub/blob/main/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/conda-store/variables.tf#L70 as a variable with the secret token along with permissions needed.

here you will need to create a function which calls the conda-store kubernetes service api with this endpoint https://conda-store.readthedocs.io/en/latest/api.html#/api/api_list_environments_api_v1_environment__get.

Getting started it might be easiest to hardcode the api token that is added to the conda-store config in order to test the api calls from cdsdashboards.

Later we can talk about how to link them in terraform code. We will likely do tricks similar to how this same pattern is handled in jupyterhub https://github.com/Quansight/qhub/blob/main/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/variables.tf#L84-L87.

@viniciusdc viniciusdc added the status: in progress 🏗 This task is currently being worked on label Sep 1, 2022
@viniciusdc
Copy link
Contributor

viniciusdc commented Sep 1, 2022

@costrouc Tokens and the above configuration were all completed. I am working on a basic function to call the API.

Comment on lines 8 to 9
kubernetes.client.models.V1EndpointPort = kubernetes.client.models.CoreV1EndpointPort

Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this line generated the following error:

 Loading extra config: 01-theme.py                                                                                                                                      │
│ Loading extra config: 02-spawner.py                                                                                                                                    │
│ [E 2022-09-05 18:46:15.302 JupyterHub app:2989]                                                                                                                        │
│     Traceback (most recent call last):                                                                                                                                 │
│       File "/opt/conda/lib/python3.7/site-packages/jupyterhub/app.py", line 2986, in launch_instance_async                                                             │
│         await self.initialize(argv)                                                                                                                                    │
│       File "/opt/conda/lib/python3.7/site-packages/jupyterhub/app.py", line 2477, in initialize                                                                        │
│         self.load_config_file(self.config_file)                                                                                                                        │
│       File "/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py", line 110, in inner                                                                │
│         return method(app, *args, **kwargs)                                                                                                                            │
│       File "/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py", line 889, in load_config_file                                                     │
│         raise_config_file_errors=self.raise_config_file_errors,                                                                                                        │
│       File "/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py", line 844, in _load_config_files                                                   │
│         config = loader.load_config()                                                                                                                                  │
│       File "/opt/conda/lib/python3.7/site-packages/traitlets/config/loader.py", line 625, in load_config                                                               │
│         self._read_file_as_dict()                                                                                                                                      │
│       File "/opt/conda/lib/python3.7/site-packages/traitlets/config/loader.py", line 658, in _read_file_as_dict                                                        │
│         exec(compile(f.read(), conf_filename, "exec"), namespace, namespace)                                                                                           │
│       File "/usr/local/etc/jupyterhub/jupyterhub_config.py", line 446, in <module>                                                                                     │
│         exec(config_py)                                                                                                                                                │
│       File "<string>", line 5, in <module>                                                                                                                             │
│       File "/opt/conda/lib/python3.7/site-packages/kubespawner/__init__.py", line 13, in <module>                                                                      │
│         from kubespawner.spawner import KubeSpawner                                                                                                                    │
│       File "/opt/conda/lib/python3.7/site-packages/kubespawner/spawner.py", line 42, in <module>                                                                       │
│         from .objects import make_namespace                                                                                                                            │
│       File "/opt/conda/lib/python3.7/site-packages/kubespawner/objects.py", line 16, in <module>                                                                       │
│         from kubernetes.client.models import V1EndpointPort                                                                                                            │
│     ImportError: cannot import name 'V1EndpointPort' from 'kubernetes.client.models' (/opt/conda/lib/python3.7/site-packages/kubernetes/client/models/__init__.py) 

Which made the Hub deployment enter a crash loop cycle. Returning the block above fixed the problem.

@viniciusdc
Copy link
Contributor

viniciusdc commented Sep 6, 2022

It needs to be tested with QHUB_IMAGE_TAG=sha-563ef5c for the docker images, waiting for 0.4.4 release.

@viniciusdc
Copy link
Contributor

viniciusdc commented Sep 7, 2022

Blocked by ideonate/cdsdashboards#107, I was able to test this locally, though lets-encrypt didn't want to cooperate providing a valid cert... so I was unable to properly "see" the dashboard. Still, it was successfully launched with the mentioned changes in cdsdashboards.

@viniciusdc
Copy link
Contributor

This is ready for review, when testing please be sure to use the latest available image from main

Copy link
Member Author

@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.

Will need to wait for a new release of Conda-Store which I will be releasing tonight.

@viniciusdc
Copy link
Contributor

I will do another drive-test on this, then we are set

@viniciusdc
Copy link
Contributor

Tested, and all seems to be working!!!
Captura de tela de 2022-09-27 12 57 26
The new envs are dynamically updated in the dropdown menu once built on conda-store (cdsdashboards is required at least)

Captura de tela de 2022-09-27 12 59 16
with the recent changes made to conda-store 0.4.12, we now have these weird names on the main page, but we can address this later.

@viniciusdc
Copy link
Contributor

Thanks for updating the cypress tests @iameskild, once you approve, this is ready to be merged. Something that we will need to check once v0.4.5rc shows up in beta, is how conda-store old environments will behave with the name changes (we are modifying the exposed env names with this config c.CondaStore.environment_directory)

Copy link
Member

@iameskild iameskild left a comment

Choose a reason for hiding this comment

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

@viniciusdc I tested this myself and it works wonderfully :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: integration/conda-store status: in progress 🏗 This task is currently being worked on
Projects
Status: Done 💪🏾
4 participants