From 25b2eaa95741224a24685bae8688f1aa8348d49e Mon Sep 17 00:00:00 2001 From: Christopher Ostrouchov Date: Fri, 4 Feb 2022 11:01:18 -0500 Subject: [PATCH] Fixing cdsdashboard conda environments being shown (#1025) This is a short term fix for conda-store environments being shown in cdsdashboards. Longer term we will need to consult the conda-store rest api or filesystem for available environments (for 0.4.x release). Fixes #1019 --- qhub/template/stages/07-kubernetes-services/jupyterhub.tf | 1 + .../kubernetes/services/jupyterhub/files/02-spawner.py | 5 ++--- .../modules/kubernetes/services/jupyterhub/main.tf | 1 + .../modules/kubernetes/services/jupyterhub/variables.tf | 6 ++++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/qhub/template/stages/07-kubernetes-services/jupyterhub.tf b/qhub/template/stages/07-kubernetes-services/jupyterhub.tf index e4b43ab85f..9f1dcfcd96 100644 --- a/qhub/template/stages/07-kubernetes-services/jupyterhub.tf +++ b/qhub/template/stages/07-kubernetes-services/jupyterhub.tf @@ -92,6 +92,7 @@ module "jupyterhub" { conda-store-pvc = module.conda-store-nfs-mount.persistent_volume_claim.name conda-store-mount = "/home/conda" + conda-store-environments = var.conda-store-environments extra-mounts = { "/etc/dask" = { diff --git a/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/files/02-spawner.py b/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/files/02-spawner.py index 318ec1fbb9..5ab464c99e 100644 --- a/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/files/02-spawner.py +++ b/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/files/02-spawner.py @@ -8,6 +8,7 @@ import z2jh cdsdashboards = z2jh.get_config("custom.cdsdashboards") +conda_store_environments = z2jh.get_config("custom.environments") if cdsdashboards["enabled"]: from cdsdashboards.hubextension.spawners.variablekube import VariableKubeSpawner @@ -31,9 +32,7 @@ c.CDSDashboardsConfig.spawn_default_options = False c.CDSDashboardsConfig.conda_envs = [ - # {%- for key in cookiecutter.environments %} - # "{{ cookiecutter.environments[key].name }}", - # {%- endfor %} + environment['name'] for _, environment in conda_store_environments.items() ] else: c.JupyterHub.allow_named_servers = False diff --git a/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/main.tf b/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/main.tf index 6be9053f8f..07816becc5 100644 --- a/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/main.tf +++ b/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/main.tf @@ -31,6 +31,7 @@ resource "helm_release" "jupyterhub" { conda-store-pvc = var.conda-store-pvc conda-store-mount = var.conda-store-mount extra-mounts = var.extra-mounts + environments = var.conda-store-environments } hub = { diff --git a/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/variables.tf b/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/variables.tf index 425772b332..68a5780813 100644 --- a/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/variables.tf +++ b/qhub/template/stages/07-kubernetes-services/modules/kubernetes/services/jupyterhub/variables.tf @@ -110,3 +110,9 @@ variable "cdsdashboards" { cds_hide_user_dashboard_servers = false } } + +variable "conda-store-environments" { + description = "conda environments from conda-store in filesystem namespace" + type = map(any) + default = {} +}