Small fixes for k8s.

This commit is contained in:
John Chilton
2019-11-12 09:05:41 -05:00
parent 0e4fb6a22a
commit 301d026bfb
+2 -2
View File
@@ -503,7 +503,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
job.api.raise_for_status(r)
def __job_failed_due_to_walltime_limit(self, job):
conditions = job.obj['status']['conditions']
conditions = job.obj['status'].get('conditions') or []
return any(True for c in conditions if c['type'] == 'Failed' and c['reason'] == 'DeadlineExceeded')
def __job_failed_due_to_low_memory(self, job_state):
@@ -532,7 +532,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
jobs = Job.objects(self._pykube_api).filter(
selector="app=" + self.__produce_unique_k8s_job_name(job.get_id_tag()),
namespace=self.runner_params['k8s_namespace'])
if len(jobs.response['items']) >= 0:
if len(jobs.response['items']) > 0:
job_to_delete = Job(self._pykube_api, jobs.response['items'][0])
self.__cleanup_k8s_job(job_to_delete)
# TODO assert whether job parallelism == 0