Skip to content

Commit 0b64cce

Browse files
authored
Merge pull request #646 from MetaCell/release/1.0.2
Release/1.0.2
2 parents d523ac0 + 5926d4d commit 0b64cce

2 files changed

Lines changed: 35 additions & 8 deletions

File tree

applications/jupyterhub/src/harness_jupyter/harness_jupyter/jupyterhub.py

100755100644
Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@
44
import urllib.parse
55

66
from kubespawner.spawner import KubeSpawner
7+
8+
from cloudharness.applications import get_configuration
9+
from cloudharness.auth.quota import get_user_quotas
10+
from cloudharness.utils.config import CloudharnessConfig as conf
11+
12+
713
handler = logging.StreamHandler(sys.stdout)
814
handler.setLevel(logging.DEBUG)
915
logging.getLogger().addHandler(handler)
1016

11-
from cloudharness.applications import get_configuration
12-
from cloudharness.auth.quota import get_user_quotas
17+
def custom_options_form(spawner, abc):
18+
# let's skip the profile selection form for now
19+
# ToDo: for future we can remove this hook
20+
spawner.profile_list = []
21+
# ref: https://github.com/jupyterhub/kubespawner/blob/37a80abb0a6c826e5c118a068fa1cf2725738038/kubespawner/spawner.py#L1885-L1935
22+
return spawner._options_form_default()
1323

1424

1525
class PodSpawnException(Exception):
@@ -20,6 +30,9 @@ def harness_hub():
2030
"""Wraps the method to change spawner configuration"""
2131
KubeSpawner.get_pod_manifest_base = KubeSpawner.get_pod_manifest
2232
KubeSpawner.get_pod_manifest = spawner_pod_manifest
33+
# let's skip the profile selection form for now
34+
# TODO: for future we can remove this hook
35+
KubeSpawner.options_form = custom_options_form
2336
KubeSpawner.get_pvc_manifest_base = KubeSpawner.get_pvc_manifest
2437
KubeSpawner.get_pvc_manifest = spawner_pvc_manifest
2538

@@ -105,7 +118,6 @@ def change_pod_manifest(self: KubeSpawner):
105118
self.user.name, quota_ws_open
106119
),
107120
)
108-
109121
try:
110122
subdomain = self.handler.request.host.split(str(self.config['domain']))[0][0:-1]
111123
app_config = self.config['apps']
@@ -115,9 +127,23 @@ def change_pod_manifest(self: KubeSpawner):
115127
harness = app['harness']
116128

117129
if 'subdomain' in harness and harness['subdomain'] == subdomain:
118-
if app['name'] != 'jupyterhub': # Would use the hub image in that case, which we don't want.
119-
print('Change image to', harness['deployment']['image'])
120-
self.image = harness['deployment']['image']
130+
ws_image = getattr(self, "ws_image", None)
131+
if ws_image:
132+
# try getting the image + tag from values.yaml
133+
ch_conf = conf.get_configuration()
134+
task_images = ch_conf['task-images']
135+
for task_image in task_images:
136+
image_plus_tag = task_images[task_image]
137+
if ws_image in image_plus_tag:
138+
ws_image = image_plus_tag
139+
logging.error(f'Found tag for image: {ws_image}')
140+
break
141+
else:
142+
if app['name'] != 'jupyterhub': # Would use the hub image in that case, which we don't want.
143+
ws_image = harness['deployment']['image']
144+
if ws_image:
145+
logging.info(f'Change image to {ws_image}')
146+
self.image = ws_image
121147
if registry['name'] in self.image and registry['secret']:
122148
self.image_pull_secrets = registry['secret']
123149

libraries/cloudharness-common/requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ certifi==2019.3.9
33
chardet==3.0.4
44
idna==2.8
55
pyjwt==2.6.0
6-
pyOpenSSL==22.1.0
6+
pyOpenSSL<22.1.0
77
PySocks==1.6.8
88
requests>=2.27.0
99
ruamel.yaml==0.17.21
@@ -16,6 +16,7 @@ kubernetes
1616
sentry-sdk[flask]==0.14.4
1717
python-keycloak==2.6.0
1818
argo-workflows==5.0.0
19+
cryptography<3.4
1920
hypothesis==6.54.2
2021
jsonschema<4.0.0
21-
httpx==0.23.0
22+
httpx==0.23.0

0 commit comments

Comments
 (0)