Skip to content
Snippets Groups Projects

Pass labels to tunnel drf via headers

Merged alice grosch requested to merge dev into main
7 files
+ 27
17
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -110,10 +110,21 @@ class SpawnProgressUpdateAPIHandler(APIHandler):
event["setup_tunnel"]["servername"] = spawner.name
event["setup_tunnel"]["svc_port"] = spawner.port
event["setup_tunnel"]["svc_name"] = spawner.svc_name
labels = {
"hub.jupyter.org/username": user.name,
"hub.jupyter.org/servername": spawner.name,
"component": "singleuser-server",
"app": os.environ.get("JUPYTERHUB_APP", "jupyterhub"),
}
for param, value in spawner.user_options.items():
key = f"hub.jupyter.org/{param}"
value = value.replace('/', '-') # cannot have '/' in k8s label values
labels.update({key: value})
custom_config = user.authenticator.custom_config
req_prop = drf_request_properties(
"tunnel", custom_config, self.log, uuidcode
)
req_prop["headers"]["labels"] = json.dumps(labels) # Add labels to headers
service_url = req_prop.get("urls", {}).get("tunnel", "None")
req = HTTPRequest(
service_url,
Loading