Skip to content

Commit 475623e

Browse files
committed
Use hex value for k8s job ID instead of pod name
1 parent fe9e919 commit 475623e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

parsl/providers/kubernetes/kube.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ def submit(self, cmd_string: str, tasks_per_node: int, job_name: str = "parsl.ku
188188
volumes=self.persistent_volumes,
189189
service_account_name=self.service_account_name,
190190
annotations=self.annotations)
191-
self.resources[pod_name] = {'status': JobStatus(JobState.RUNNING)}
191+
self.resources[job_id] = {'status': JobStatus(JobState.RUNNING), 'pod_name': pod_name}
192192

193-
return pod_name
193+
return job_id
194194

195195
def status(self, job_ids):
196196
""" Get the status of a list of jobs identified by the job identifiers
@@ -206,6 +206,9 @@ def status(self, job_ids):
206206
self._status()
207207
return [self.resources[jid]['status'] for jid in job_ids]
208208

209+
def _get_pod_name(self, job_id: str) -> str:
210+
return self.resources[job_id]['pod_name']
211+
209212
def cancel(self, job_ids):
210213
""" Cancels the jobs specified by a list of job ids
211214
Args:
@@ -215,7 +218,8 @@ def cancel(self, job_ids):
215218
"""
216219
for job in job_ids:
217220
logger.debug("Terminating job/pod: {0}".format(job))
218-
self._delete_pod(job)
221+
pod_name = self._get_pod_name(job)
222+
self._delete_pod(pod_name)
219223

220224
self.resources[job]['status'] = JobStatus(JobState.CANCELLED)
221225
rets = [True for i in job_ids]
@@ -236,7 +240,8 @@ def _status(self):
236240
for jid in to_poll_job_ids:
237241
phase = None
238242
try:
239-
pod = self.kube_client.read_namespaced_pod(name=jid, namespace=self.namespace)
243+
pod_name = self._get_pod_name(jid)
244+
pod = self.kube_client.read_namespaced_pod(name=pod_name, namespace=self.namespace)
240245
except Exception:
241246
logger.exception("Failed to poll pod {} status, most likely because pod was terminated".format(jid))
242247
if self.resources[jid]['status'] is JobStatus(JobState.RUNNING):

0 commit comments

Comments
 (0)