Skip to content

Commit 57395b0

Browse files
committed
Address changes in docs and deployment scripts
1 parent 43032d6 commit 57395b0

File tree

16 files changed

+47
-46
lines changed

16 files changed

+47
-46
lines changed

docs/source/developers/custom-images.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,6 @@ cp -r python_kubernetes python_myCustomKernel
164164
}
165165
```
166166

167-
- If using a whitelist (`EG_KERNEL_WHITELIST`), be sure to update it with the new kernel specification directory name (e.g., `python_myCustomKernel`) and restart/redeploy Enterprise Gateway.
167+
- If using kernel filtering (`EG_ALLOWED_KERNELS`), be sure to update it with the new kernel specification directory name (e.g., `python_myCustomKernel`) and restart/redeploy Enterprise Gateway.
168168
- Launch or refresh your Notebook session and confirm `My Custom Kernel` appears in the _new kernel_ drop-down.
169169
- Create a new notebook using `My Custom Kernel`.

docs/source/operators/config-cli.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ EnterpriseGatewayApp(EnterpriseGatewayConfigMixin, JupyterApp) options
121121
The full path to a certificate authority certificate for SSL/TLS client
122122
authentication. (EG_CLIENT_CA env var)
123123
Default: None
124+
--EnterpriseGatewayApp.client_envs=<list-item-1>...
125+
Environment variables allowed to be set when a client requests a
126+
new kernel. (EG_CLIENT_ENVS env var)
127+
Default: []
124128
--EnterpriseGatewayApp.conductor_endpoint=<Unicode>
125129
The http url for accessing the Conductor REST API. (EG_CONDUCTOR_ENDPOINT
126130
env var)
@@ -140,13 +144,10 @@ EnterpriseGatewayApp(EnterpriseGatewayConfigMixin, JupyterApp) options
140144
(EG_DYNAMIC_CONFIG_INTERVAL env var)
141145
Default: 0
142146
--EnterpriseGatewayApp.env_process_whitelist=<list-item-1>...
143-
Environment variables allowed to be inherited from the spawning process by
144-
the kernel. (EG_ENV_PROCESS_WHITELIST env var)
147+
DEPRECATED, use inherited_envs
145148
Default: []
146149
--EnterpriseGatewayApp.env_whitelist=<list-item-1>...
147-
Environment variables allowed to be set when a client requests a new kernel.
148-
Use '*' to allow all environment variables sent in the request.
149-
(EG_ENV_WHITELIST env var)
150+
DEPRECATED, use client_envs.
150151
Default: []
151152
--EnterpriseGatewayApp.expose_headers=<Unicode>
152153
Sets the Access-Control-Expose-Headers header. (EG_EXPOSE_HEADERS env var)
@@ -158,6 +159,10 @@ EnterpriseGatewayApp(EnterpriseGatewayConfigMixin, JupyterApp) options
158159
Indicates whether impersonation will be performed during kernel launch.
159160
(EG_IMPERSONATION_ENABLED env var)
160161
Default: False
162+
--EnterpriseGatewayApp.inherited_envs=<list-item-1>...
163+
Environment variables allowed to be inherited
164+
from the spawning process by the kernel. (EG_INHERITED_ENVS env var)
165+
Default: []
161166
--EnterpriseGatewayApp.ip=<Unicode>
162167
IP address on which to listen (EG_IP env var)
163168
Default: '127.0.0.1'

docs/source/operators/config-kernel-override.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ those same-named variables in the kernel.json `env` stanza.
3838

3939
Environment variables for which this can occur are any variables prefixed with `KERNEL_`
4040
as well as any variables
41-
listed in the `EnterpriseGatewayApp.env_whitelist` configurable trait (or via
42-
the `EG_ENV_WHITELIST` variable). Locally defined variables listed in `EG_PROCESS_ENV_WHITELIST`
41+
listed in the `EnterpriseGatewayApp.client_envs` configurable trait (or via
42+
the `EG_CLIENT_ENVS` variable). Likewise, environment variables of the Enterprise Gateway
43+
server process listed in the `EnterpriseGatewayApp.inherited_envs` configurable trait
44+
(or via the `EG_INHERITED_ENVS` variable)
4345
are also available for replacement in the kernel process' environment.
4446

4547
See [Kernel Environment Variables](../users/kernel-envs.md) in the Users documentation section for a complete set of recognized `KERNEL_` variables.

enterprise_gateway/enterprisegatewayapp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ def init_webapp(self) -> None:
236236
eg_expose_headers=self.expose_headers,
237237
eg_max_age=self.max_age,
238238
eg_max_kernels=self.max_kernels,
239-
eg_env_process_whitelist=self.env_process_whitelist,
240-
eg_env_whitelist=self.env_whitelist,
239+
eg_inherited_envs=self.inherited_envs,
240+
eg_client_envs=self.client_envs,
241241
eg_kernel_headers=self.kernel_headers,
242242
eg_list_kernels=self.list_kernels,
243243
eg_authorized_users=self.authorized_users,

enterprise_gateway/mixins.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,9 @@ def list_kernels_default(self) -> bool:
374374

375375
env_whitelist = ListTrait(
376376
config=True,
377-
help="""DEPRECATED, use allowed_envs.""",
377+
help="""DEPRECATED, use client_envs.""",
378378
)
379379

380-
@default("env_whitelist")
381-
def env_whitelist_default(self) -> List[str]:
382-
return os.getenv(self.env_whitelist_env, os.getenv("KG_ENV_WHITELIST", "")).split(",")
383-
384380
@observe("env_whitelist")
385381
def _update_env_whitelist(self, change):
386382
self.log.warning("env_whitelist is deprecated, use client_envs")

enterprise_gateway/services/api/swagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
},
161161
"env": {
162162
"type": "object",
163-
"description": "A dictionary of environment variables and values to include in the kernel process - subject to whitelisting.",
163+
"description": "A dictionary of environment variables and values to include in the kernel process - subject to filtering.",
164164
"additionalProperties": {
165165
"type": "string"
166166
}

enterprise_gateway/services/api/swagger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ paths:
141141
type: object
142142
description: |
143143
A dictionary of environment variables and values to include in the
144-
kernel process - subject to whitelisting.
144+
kernel process - subject to filtering.
145145
additionalProperties:
146146
type: string
147147
responses:

enterprise_gateway/services/kernels/handlers.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ class MainKernelHandler(
2222
"""
2323

2424
@property
25-
def env_whitelist(self):
26-
return self.settings["eg_env_whitelist"]
25+
def client_envs(self):
26+
return self.settings["eg_client_envs"]
2727

2828
@property
29-
def env_process_whitelist(self):
30-
return self.settings["eg_env_process_whitelist"]
29+
def inherited_envs(self):
30+
return self.settings["eg_inherited_envs"]
3131

3232
async def post(self):
3333
"""Overrides the super class method to manage env in the request body.
@@ -59,19 +59,15 @@ async def post(self):
5959
{
6060
key: value
6161
for key, value in os.environ.items()
62-
if key in self.env_process_whitelist
62+
if key in self.inherited_envs
6363
}
6464
)
65-
# Whitelist KERNEL_* args and those allowed by configuration from client. If all
66-
# envs are requested, just use the keys from the payload.
67-
env_whitelist = self.env_whitelist
68-
if env_whitelist == ["*"]:
69-
env_whitelist = model["env"].keys()
65+
# Allow KERNEL_* args and those allowed by configuration.
7066
env.update(
7167
{
7268
key: value
7369
for key, value in model["env"].items()
74-
if key.startswith("KERNEL_") or key in env_whitelist
70+
if key.startswith("KERNEL_") or key in self.client_envs
7571
}
7672
)
7773

enterprise_gateway/services/kernels/remotemanager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ def _link_dependent_props(self):
427427
"port_range",
428428
"impersonation_enabled",
429429
"max_kernels_per_user",
430-
"env_whitelist",
431-
"env_process_whitelist",
430+
"client_envs",
431+
"inherited_envs",
432432
"yarn_endpoint",
433433
"alt_yarn_endpoint",
434434
"yarn_endpoint_security_enabled",
@@ -470,8 +470,8 @@ def _capture_user_overrides(self, **kwargs):
470470
key: value
471471
for key, value in env.items()
472472
if key.startswith("KERNEL_")
473-
or key in self.env_process_whitelist
474-
or key in self.env_whitelist
473+
or key in self.inherited_envs
474+
or key in self.client_envs
475475
}
476476
)
477477

enterprise_gateway/services/processproxies/k8s.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async def launch_process(
5353
# transfer its env to each launched kernel.
5454
kwargs["env"] = dict(
5555
os.environ, **kwargs["env"]
56-
) # FIXME: Should probably use process-whitelist in JKG #280
56+
)
5757
self.kernel_pod_name = self._determine_kernel_pod_name(**kwargs)
5858
self.kernel_namespace = self._determine_kernel_namespace(
5959
**kwargs

enterprise_gateway/tests/test_handlers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ def setup_app(self):
2424
os.environ["JUPYTER_PATH"] = RESOURCES
2525

2626
# These are required for setup of test_kernel_defaults
27+
# Note: We still reference the DEPRECATED config parameter and environment variable so that
28+
# we can test client_envs and inherited_envs, respectively.
29+
self.app.env_whitelist = ['TEST_VAR', 'OTHER_VAR1', 'OTHER_VAR2']
2730
os.environ["EG_ENV_PROCESS_WHITELIST"] = "PROCESS_VAR1,PROCESS_VAR2"
2831
os.environ["PROCESS_VAR1"] = "process_var1_override"
2932

30-
self.app.env_whitelist = ["TEST_VAR", "OTHER_VAR1", "OTHER_VAR2"]
31-
3233
def tearDown(self):
3334
"""Shuts down the app after test run."""
3435

etc/docker/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ services:
2222
- "EG_DOCKER_NETWORK=${EG_DOCKER_NETWORK:-enterprise-gateway_enterprise-gateway}"
2323
- "EG_KERNEL_LAUNCH_TIMEOUT=${EG_KERNEL_LAUNCH_TIMEOUT:-60}"
2424
- "EG_CULL_IDLE_TIMEOUT=${EG_CULL_IDLE_TIMEOUT:-3600}"
25-
- "EG_KERNEL_WHITELIST=${EG_KERNEL_WHITELIST:-'r_docker','python_docker','python_tf_docker','python_tf_gpu_docker','scala_docker'}"
25+
# Use double-defaulting for B/C. Support for EG_KERNEL_WHITELIST will be removed in a future release
26+
- "EG_ALLOWED_KERNELS=${EG_ALLOWED_KERNELS:-${EG_KERNEL_WHITELIST:-'r_docker','python_docker','python_tf_docker','python_tf_gpu_docker','scala_docker'}}"
2627
- "EG_MIRROR_WORKING_DIRS=${EG_MIRROR_WORKING_DIRS:-False}"
2728
- "EG_RESPONSE_PORT=${EG_RESPONSE_PORT:-8877}"
2829
- "KG_PORT=${KG_PORT:-8888}"

etc/docker/enterprise-gateway/start-enterprise-gateway.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ export EG_LOG_LEVEL=${EG_LOG_LEVEL:-DEBUG}
2626
export EG_CULL_IDLE_TIMEOUT=${EG_CULL_IDLE_TIMEOUT:-43200} # default to 12 hours
2727
export EG_CULL_INTERVAL=${EG_CULL_INTERVAL:-60}
2828
export EG_CULL_CONNECTED=${EG_CULL_CONNECTED:-False}
29-
EG_KERNEL_WHITELIST=${EG_KERNEL_WHITELIST:-"null"}
30-
export EG_KERNEL_WHITELIST=`echo ${EG_KERNEL_WHITELIST} | sed 's/[][]//g'` # sed is used to strip off surrounding brackets as they should no longer be included.
29+
EG_ALLOWED_KERNELS=${EG_ALLOWED_KERNELS:-${EG_KERNEL_WHITELIST:-"null"}}
30+
export EG_ALLOWED_KERNELS=`echo ${EG_ALLOWED_KERNELS} | sed 's/[][]//g'` # sed is used to strip off surrounding brackets as they should no longer be included.
3131
export EG_DEFAULT_KERNEL_NAME=${EG_DEFAULT_KERNEL_NAME:-python_docker}
3232

3333
# Determine whether the kernels-allowed list should be added to the start command.
3434
# This is conveyed via a 'null' value for the env - which indicates no kernel names
3535
# were used in the helm chart or docker-compose yaml.
3636
allowed_kernels_option=""
37-
if [ "${EG_KERNEL_WHITELIST}" != "null" ]; then
38-
allowed_kernels_option="--KernelSpecManager.whitelist=[${EG_KERNEL_WHITELIST}]"
37+
if [ "${EG_ALLOWED_KERNELS}" != "null" ]; then
38+
# Update to --KernelSpecManager.allowed_kernelspecs once jupyter_client >= 7 can be supported
39+
allowed_kernels_option="--KernelSpecManager.whitelist=[${EG_ALLOWED_KERNELS}]"
3940
fi
4041

41-
4242
echo "Starting Jupyter Enterprise Gateway..."
4343

4444
exec jupyter enterprisegateway \

etc/kernel-launchers/docker/scripts/launch_docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def launch_docker_kernel(kernel_id, port_range, response_addr, public_key, spark
4242
param_env["RESPONSE_ADDRESS"] = response_addr
4343
param_env["KERNEL_SPARK_CONTEXT_INIT_MODE"] = spark_context_init_mode
4444

45-
# Since the environment is specific to the kernel (per env stanza of kernelspec, KERNEL_ and ENV_WHITELIST)
45+
# Since the environment is specific to the kernel (per env stanza of kernelspec, KERNEL_ and EG_CLIENT_ENVS)
4646
# just add the env here.
4747
param_env.update(os.environ)
4848
param_env.pop(

etc/kubernetes/helm/enterprise-gateway/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ spec:
6969
value: {{ .Values.logLevel }}
7070
- name: EG_KERNEL_LAUNCH_TIMEOUT
7171
value: !!str {{ .Values.kernel.launchTimeout }}
72-
- name: EG_KERNEL_WHITELIST
73-
value: {{ toJson .Values.kernel.whitelist | squote }}
72+
- name: EG_ALLOWED_KERNELS
73+
value: {{ toJson .Values.kernel.allowedKernels | squote }}
7474
- name: EG_DEFAULT_KERNEL_NAME
7575
value: {{ .Values.kernel.defaultKernelName }}
7676
# Optional authorization token passed in all requests

etc/kubernetes/helm/enterprise-gateway/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ kernel:
7878
cullIdleTimeout: 3600
7979
# List of kernel names that are available for use. To allow additional kernelspecs without
8080
# requiring redeployment (and assuming kernelspecs are mounted or otherwise accessible
81-
# outside the pod), comment out (or remove) the entries, leaving only `whitelist:`.
82-
whitelist:
81+
# outside the pod), comment out (or remove) the entries, leaving only `allowedKernels:`.
82+
allowedKernels:
8383
- r_kubernetes
8484
- python_kubernetes
8585
- python_tf_kubernetes

0 commit comments

Comments
 (0)