Skip to content

Commit

Permalink
fix: Mount /dev/shm to the correct container.
Browse files Browse the repository at this point in the history
Currently container #1 is `oauth-proxy` while JupyterServer,
is #0.

Additionally use half of the memory requested by the pod
instead of half of the storage.

Since we rely on memory there is no need to tie the increased
/dev/shm to requesting storage in the session.

NOTE: This system of patching the manifest is very brittle and
the bug being fixed by this commit might appear again as soon
as the containers sorting changes. We should think about a different
way of interacting with the manifests of the user-sessions.
  • Loading branch information
aledegano committed Sep 18, 2024
1 parent 8b784bd commit b85d1e1
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions renku_notebooks/api/amalthea_patches/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,32 +201,31 @@ def oidc_unverified_email(server: "UserServer"):

def dev_shm(server: "UserServer"):
patches = []
if server.server_options.storage:
patches.append(
{
"type": "application/json-patch+json",
"patch": [
{
"op": "add",
"path": "/statefulset/spec/template/spec/volumes/-",
"value": {
"name": "shm",
"emptyDir": {
"medium": "Memory",
# NOTE: We are giving /dev/shm up to half of the memory request
"sizeLimit": int(server.server_options.storage / 2),
},
patches.append(
{
"type": "application/json-patch+json",
"patch": [
{
"op": "add",
"path": "/statefulset/spec/template/spec/volumes/-",
"value": {
"name": "shm",
"emptyDir": {
"medium": "Memory",
# NOTE: We are giving /dev/shm up to half of the memory request
"sizeLimit": int(server.server_options.mem_request / 2),
},
},
{
"op": "add",
"path": "/statefulset/spec/template/spec/containers/1/volumeMounts/-",
"value": {
"mountPath": "/dev/shm",
"name": "shm",
},
},
{
"op": "add",
"path": "/statefulset/spec/template/spec/containers/0/volumeMounts/-",
"value": {
"mountPath": "/dev/shm",
"name": "shm",
},
],
}
)
},
],
}
)
return patches

0 comments on commit b85d1e1

Please sign in to comment.