Skip to content

Commit

Permalink
Fix anonymous pod resources setting
Browse files Browse the repository at this point in the history
  • Loading branch information
filippomc committed Apr 24, 2024
1 parent a6d733a commit 953f07d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 76 deletions.
2 changes: 1 addition & 1 deletion applications/jupyterhub/deploy/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ singleuser:
storage:
capacity: 2Gi
cpu:
limit: 0.1
limit: 1
guarantee: 0
memory:
limit: 0.5G
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from cloudharness.auth.exceptions import UserNotFound
from urllib.parse import parse_qs, urlparse

from harness_jupyter.jupyterhub import set_key_value

allowed_chars = set(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

Expand All @@ -33,6 +35,7 @@ class CookieNotFound(Exception):
pass



def change_pod_manifest(self: KubeSpawner):
"""
Application Hook to change the manifest of the notebook image
Expand Down Expand Up @@ -135,8 +138,30 @@ def workspace_volume_is_legacy(workspace_id):
self.storage_pvc_ensure = False
self.volumes = []
self.volume_mounts = []
print("Starting anonymoous session with no volumes")

print("Setting user quota cpu/mem usage")
from cloudharness.applications import get_current_configuration, get_configuration
try:
subdomain = self.handler.request.host.split(
str(self.config['domain']))[0][0:-1]
appname = next(app["name"] for app in self.config['apps'].values(
) if app["harness"]["subdomain"] == subdomain)
app_conf = get_configuration(appname).to_dict()
cpu_conf = app_conf.get("singleuser", {}).get("cpu", {})
mem_conf = app_conf.get("singleuser", {}).get("memory", {})
except StopIteration:
cpu_conf = {}
mem_conf = {}

jh_conf = get_configuration('jupyterhub')
cpu_conf = {**jh_conf.singleuser["cpu"].to_dict(), **cpu_conf}
mem_conf = {**jh_conf.singleuser["memory"].to_dict(), **mem_conf}
set_key_value(self, key="cpu_guarantee", value=cpu_conf["guarantee"])
set_key_value(self, key="cpu_limit", value=cpu_conf["limit"])
set_key_value(self, key="mem_guarantee",
value=mem_conf["guarantee"])
set_key_value(self, key="mem_limit", value=mem_conf["limit"])
print("Starting anonymous session with no volumes")
except Exception as e:
log.error('Change pod manifest failed due to an error.', exc_info=True)

Expand All @@ -159,8 +184,6 @@ def workspace_volume_is_legacy(workspace_id):
})




def get_app_user(user: User):
auth_client = AuthClient()
kc_user = auth_client.get_user(user.name)
Expand Down
6 changes: 6 additions & 0 deletions applications/jupyterlab-minimal/deploy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ harness:
c.JupyterHub.tornado_settings = { "headers": { "Content-Security-Policy": "frame-ancestors *"}}
singleuser:
storage:
capacity: 2Mi
cpu:
limit: 3
guarantee: 0.13
72 changes: 0 additions & 72 deletions applications/workspaces/server/requirements copy.txt

This file was deleted.

0 comments on commit 953f07d

Please sign in to comment.