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

Merge hub.extraEnv env vars #968

Merged
merged 4 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: v2.3.0
hooks:
- id: check-yaml
exclude: 'qhub/template/\{\{ cookiecutter\.repo_directory \}\}/\.github/.*'
exclude: 'qhub/template/\{\{ cookiecutter\.repo_directory \}\}/(\.github/.*|infrastructure/jupyterhub.yaml)'
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
Expand Down
4 changes: 4 additions & 0 deletions docs/source/admin_guide/jupyterhub.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ jupyterhub:
```

Where it is possible to influence a value using 'native' QHub configuration, you should use that as a preference. For example, you would not set `jupyterhub.overrides.hub.image.name` to use a custom JupyterHub Docker image. Instead you would set `default_images.jupyterhub`.

There is special behavior for the values `jupyterhub.overrides.hub.extraEnv` and `jupyterhub.overrides.hub.extraConfig`. Setting these would have naturally seen them be overridden in their entirety by QHub's own values, but there is special treatment whereby QHub's values are merged into the list of any values that you might have set as overrides.

In general, it is possible that other overrides will always be lost where QHub sets its own values, so caution must be taken, and in debugging ensure that you are prepared for unexpected results when using overrides.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ dependencies:
- cdsdashboards==0.6.0
- jupyterhub-idle-culler==1.0
- pip:
- qhub-jupyterhub-theme==0.3.2
- qhub-jupyterhub-theme==0.3.3
- python-keycloak==0.26.1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ hub:
{% include "templates/jupyterhub_config.py.j2" %}
{% endfilter %}

{% if cookiecutter.jupyterhub is defined and cookiecutter.jupyterhub.overrides is defined and cookiecutter.jupyterhub.overrides.hub is defined and cookiecutter.jupyterhub.overrides.hub.extraConfig is defined %}
{% filter indent(width=4) %}
{{ cookiecutter.jupyterhub.overrides.hub.extraConfig | default({}) | yamlify -}}
{% endfilter %}
{% endif %}

singleuser:
storage:
homeMountPath: /home/jovyan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ module "qhub" {
{%- endif %}
)

{%- if cookiecutter.jupyterhub is defined and cookiecutter.jupyterhub.overrides is defined and cookiecutter.jupyterhub.overrides.hub is defined and cookiecutter.jupyterhub.overrides.hub.extraEnv is defined %}
jupyterhub-hub-extraEnv = {{- cookiecutter.jupyterhub.overrides.hub.extraEnv | default({}) | jsonify -}}
{%- endif %}

dask_gateway_extra_config = file("dask_gateway_config.py.j2")

forwardauth-callback-url-path = local.forwardauth-callback-url-path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module "kubernetes-jupyterhub" {
overrides = concat(var.jupyterhub-overrides, [
jsonencode({
hub = {
extraEnv = [
extraEnv = concat( var.jupyterhub-hub-extraEnv,
[
{
name = "OAUTH_CLIENT_ID",
value = var.OAUTH_CLIENT_ID
Expand Down Expand Up @@ -57,7 +58,7 @@ module "kubernetes-jupyterhub" {
name = "KEYCLOAK_PASSWORD"
value = var.keycloak_password
}
]
])
nodeSelector = {
(var.general-node-group.key) = var.general-node-group.value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ variable "jupyterhub-overrides" {
type = list(string)
}

variable "jupyterhub-hub-extraEnv" {
description = "Extracted overrides to merge with jupyterhub.hub.extraEnv"
type = list(map(any))
default = []
}

variable "dask_gateway_extra_config" {
description = "dask gateway extra configuration"
type = string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,11 @@ c.JupyterHub.extra_handlers = []

# ==================== THEME =========================
import tornado.web
import qhub_jupyterhub_theme
from qhub_jupyterhub_theme import theme_extra_handlers, theme_template_paths

c.JupyterHub.extra_handlers += [
(r'/custom/(.*)', tornado.web.StaticFileHandler, {"path": qhub_jupyterhub_theme.STATIC_PATH}),
]
c.JupyterHub.extra_handlers += theme_extra_handlers

c.JupyterHub.template_paths = [
qhub_jupyterhub_theme.TEMPLATE_PATH
] + c.JupyterHub.template_paths
c.JupyterHub.template_paths = theme_template_paths + c.JupyterHub.template_paths

c.JupyterHub.template_vars = {
{%- for key, value in cookiecutter.theme.jupyterhub.items() %}
Expand Down