Skip to content

Commit

Permalink
encode env vars with quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
rsarm committed Aug 28, 2024
1 parent 8385d5c commit 1076a60
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions firecrestspawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import sys
import jupyterhub
import hostlist
import httpx
import base64
import firecrest as f7t
from enum import Enum
from jinja2 import Template
Expand Down Expand Up @@ -241,6 +243,13 @@ async def submit_batch_script(self):
job_env = self.get_env()
job_env.pop('PATH')

# FIXME: These two variables may have quotes in their values.
# We encoded as base64 since quotes are not allowed
# in firecrest requests
# The job script must have a line to decode them.
for v in ("JUPYTERHUB_OAUTH_ACCESS_SCOPES", "JUPYTERHUB_OAUTH_SCOPES"):
job_env[v] = base64.b64encode(job_env[v].encode()).decode("utf-8")

script = await self._get_batch_script(**subvars)
self.log.info('Spawner submitting job using firecREST')
self.log.info('Spawner submitted script:\n' + script)
Expand All @@ -256,6 +265,12 @@ async def submit_batch_script(self):
self.log.debug(f"[client.submit] {self.job}")
self.job_id = str(self.job['jobid'])
self.log.info(f'Job {self.job_id} submitted')
# In case the connection to the firecrest server timesout
# catch httpx.ConnectTimeout since httpx.ConnectTimeout
# doesn't print anything when cought
except httpx.ConnectTimeout:
self.log.error(f"Job submission failed: httpx.ConnectTimeout")
self.job_id = ""
except Exception as e:
self.log.error(f'Job submission failed: {e}')
self.job_id = ''
Expand Down

0 comments on commit 1076a60

Please sign in to comment.