Skip to content

Commit

Permalink
Use hex value for k8s job ID instead of pod name
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmello committed Oct 21, 2024
1 parent 83278c2 commit 86ade32
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions parsl/providers/kubernetes/kube.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ def submit(self, cmd_string: str, tasks_per_node: int, job_name: str = "parsl.ku
volumes=self.persistent_volumes,
service_account_name=self.service_account_name,
annotations=self.annotations)
self.resources[pod_name] = {'status': JobStatus(JobState.RUNNING)}
self.resources[job_id] = {'status': JobStatus(JobState.RUNNING), 'pod_name': pod_name}

return pod_name
return job_id

def status(self, job_ids):
""" Get the status of a list of jobs identified by the job identifiers
Expand All @@ -214,6 +214,9 @@ def status(self, job_ids):
self._status()
return [self.resources[jid]['status'] for jid in job_ids]

def _get_pod_name(self, job_id: str) -> str:
return self.resources[job_id]['pod_name']

def cancel(self, job_ids):
""" Cancels the jobs specified by a list of job ids
Args:
Expand All @@ -223,7 +226,8 @@ def cancel(self, job_ids):
"""
for job in job_ids:
logger.debug("Terminating job/pod: {0}".format(job))
self._delete_pod(job)
pod_name = self._get_pod_name(job)
self._delete_pod(pod_name)

self.resources[job]['status'] = JobStatus(JobState.CANCELLED)
rets = [True for i in job_ids]
Expand All @@ -244,7 +248,8 @@ def _status(self):
for jid in to_poll_job_ids:
phase = None
try:
pod = self.kube_client.read_namespaced_pod(name=jid, namespace=self.namespace)
pod_name = self._get_pod_name(jid)
pod = self.kube_client.read_namespaced_pod(name=pod_name, namespace=self.namespace)
except Exception:
logger.exception("Failed to poll pod {} status, most likely because pod was terminated".format(jid))
if self.resources[jid]['status'] is JobStatus(JobState.RUNNING):
Expand Down

0 comments on commit 86ade32

Please sign in to comment.