Skip to content

Commit

Permalink
Ensure assets and packages are stored in same volume as workshop data.
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamDumpleton committed Aug 11, 2023
1 parent c903a5a commit 8bae283
Showing 1 changed file with 45 additions and 37 deletions.
82 changes: 45 additions & 37 deletions session-manager/handlers/workshopsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,16 @@ def resolve_security_policy(name):
if storage_volume_subpath:
workshop_volume_subpath = f"{storage_volume_subpath}/{workshop_volume_subpath}"

assets_volume_subpath = "assets"

if storage_volume_subpath:
assets_volume_subpath = f"{storage_volume_subpath}/{assets_volume_subpath}"

packages_volume_subpath = "packages"

if storage_volume_subpath:
packages_volume_subpath = f"{storage_volume_subpath}/{packages_volume_subpath}"

workshop_volume_intialization_required = False

if storage_volume_name:
Expand All @@ -1675,14 +1685,6 @@ def resolve_security_policy(name):
}
)

deployment_pod_template_spec["containers"][0]["volumeMounts"].append(
{
"name": "workshop-data",
"mountPath": "/home/eduk8s",
"subPath": workshop_volume_subpath,
}
)

elif storage:
workshop_volume_intialization_required = True

Expand All @@ -1693,14 +1695,6 @@ def resolve_security_policy(name):
}
)

deployment_pod_template_spec["containers"][0]["volumeMounts"].append(
{
"name": "workshop-data",
"mountPath": "/home/eduk8s",
"subPath": workshop_volume_subpath,
}
)

elif applications.is_enabled("docker"):
workshop_volume_intialization_required = True

Expand All @@ -1716,13 +1710,30 @@ def resolve_security_policy(name):
{"name": "workshop-data", "emptyDir": {}}
)

deployment_pod_template_spec["containers"][0]["volumeMounts"].append(
else:
deployment_pod_template_spec["volumes"].append(
{"name": "workshop-data", "emptyDir": {}}
)

deployment_pod_template_spec["containers"][0]["volumeMounts"].extend(
[
{
"name": "workshop-data",
"mountPath": "/home/eduk8s",
"subPath": workshop_volume_subpath,
}
)
},
{
"name": "workshop-data",
"mountPath": "/opt/assets",
"subPath": assets_volume_subpath,
},
{
"name": "workshop-data",
"mountPath": "/opt/packages",
"subPath": packages_volume_subpath,
},
]
)

if workshop_volume_intialization_required:
if CLUSTER_STORAGE_USER:
Expand Down Expand Up @@ -1849,22 +1860,11 @@ def vendir_secrets_required(contents):

pykube.Secret(api, secret_body).create()

deployment_pod_template_spec["volumes"].extend(
[
{"name": "assets-data", "emptyDir": {}},
{"name": "packages-data", "emptyDir": {}},
{
"name": "vendir-secrets",
"secret": {"secretName": f"{session_namespace}-vendir-secrets"},
},
]
)

deployment_pod_template_spec["containers"][0]["volumeMounts"].extend(
[
{"name": "assets-data", "mountPath": "/opt/assets"},
{"name": "packages-data", "mountPath": "/opt/packages"},
]
deployment_pod_template_spec["volumes"].append(
{
"name": "vendir-secrets",
"secret": {"secretName": f"{session_namespace}-vendir-secrets"},
}
)

downloads_init_container = {
Expand All @@ -1883,8 +1883,16 @@ def vendir_secrets_required(contents):
"limits": {"memory": workshop_memory},
},
"volumeMounts": [
{"name": "assets-data", "mountPath": "/opt/assets"},
{"name": "packages-data", "mountPath": "/opt/packages"},
{
"name": "workshop-data",
"mountPath": "/opt/assets",
"subPath": assets_volume_subpath,
},
{
"name": "workshop-data",
"mountPath": "/opt/packages",
"subPath": packages_volume_subpath,
},
{"name": "vendir-secrets", "mountPath": "/opt/secrets"},
{"name": "workshop-config", "mountPath": "/opt/eduk8s/config"},
],
Expand Down

0 comments on commit 8bae283

Please sign in to comment.