Skip to content

Commit 931f0a3

Browse files
author
Alan Christie
committed
feat: App now has a DM_INSTANCE_ID env variable
1 parent 80bd24c commit 931f0a3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

operator/handlers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,20 +413,26 @@ def create(spec: Dict[str, Any], name: str, namespace: str, **_: Any) -> Dict[st
413413
# If we find a key ending with '/owner', keep it
414414
# (for use as an environment variable later)
415415
instance_owner = "Unknown"
416+
instance_id = "Unknown"
416417
for label in material.get("labels", []):
417418
key, value = label.split("=")
418419
deployment_body["spec"]["template"]["metadata"]["labels"][key] = value
419420
if key.endswith("/owner"):
420421
instance_owner = value
422+
elif key.endswith("/instance-id"):
423+
instance_id = value
421424

422425
# To simplify the dynamic ENV adjustments we're about to make...
423426
c_env = deployment_body["spec"]["template"]["spec"]["containers"][0]["env"]
424427

425428
if notebook_interface != "classic":
426429
c_env.append({"name": "JUPYTER_ENABLE_LAB", "value": "true"})
427430

428-
# Add a Project UUID environment variable
431+
# Add a Project and Instance UUID environment variables
432+
# The project comes from the 'material->project' structure
433+
# the instance comes from the provided "material->label''
429434
c_env.append({"name": "DM_PROJECT_ID", "value": str(project_id)})
435+
c_env.append({"name": "DM_INSTANCE_ID", "value": str(instance_id)})
430436
# Add the instance owner (expected to have been extracted from a label)
431437
c_env.append({"name": "DM_INSTANCE_OWNER", "value": str(instance_owner)})
432438

0 commit comments

Comments
 (0)