From 34bde631f42c82d53d8bc6de9d2b2d1e964f9be9 Mon Sep 17 00:00:00 2001 From: Kiran Telukunta saraswathi Date: Mon, 8 Jul 2019 08:56:35 +0200 Subject: [PATCH 1/5] * walltime_limit added for the k8s jobs * default is also set to the k8s_walltime_limit in job specification --- lib/galaxy/jobs/runners/kubernetes.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/jobs/runners/kubernetes.py b/lib/galaxy/jobs/runners/kubernetes.py index 1dba8c47281..fadfff4fc0e 100644 --- a/lib/galaxy/jobs/runners/kubernetes.py +++ b/lib/galaxy/jobs/runners/kubernetes.py @@ -58,7 +58,8 @@ class KubernetesJobRunner(AsynchronousJobRunner): k8s_default_limits_cpu=dict(map=str, default=None), k8s_default_limits_memory=dict(map=str, default=None), k8s_pod_retries=dict(map=int, valid=lambda x: int >= 0, default=3), - k8s_pod_retrials=dict(map=int, valid=lambda x: int >= 0, default=3)) + k8s_pod_retrials=dict(map=int, valid=lambda x: int >= 0, default=3), + k8s_walltime_limit=dict(map=int, valid=lambda x: int(x) >= 0, default=172800)) if 'runner_param_specs' not in kwargs: kwargs['runner_param_specs'] = dict() @@ -220,8 +221,10 @@ class KubernetesJobRunner(AsynchronousJobRunner): return produce_unique_k8s_job_name(app_prefix='galaxy', instance_id=instance_id, job_id=galaxy_internal_job_id) def __get_k8s_job_spec(self, ajs): - """Creates the k8s Job spec. For a Job spec, the only requirement is to have a .spec.template.""" - k8s_job_spec = {"template": self.__get_k8s_job_spec_template(ajs)} + """Creates the k8s Job spec. For a Job spec, the only requirement is to have a .spec.template. + If the job hangs around unlimited it will be ended after k8s wall time limit, which sets activeDeadlineSeconds""" + k8s_job_spec = {"template": self.__get_k8s_job_spec_template(ajs), + "activeDeadlineSeconds": int(self.runner_params['k8s_walltime_limit'])} return k8s_job_spec def __get_k8s_job_spec_template(self, ajs): From 8fb5936f92641e8dc0d673274ce1cf0eb502b2b5 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 10 Jul 2019 13:49:50 +0200 Subject: [PATCH 2/5] Fix kubernetes runner on py3 instance_id is a string, so this can't be compared to an integer on python 3. Broken in ac1b25ed4c069abf1c8d810ba26d5be43717766d, prior to that the comparison was `len(self._galaxy_instance_id) > 0:` --- lib/galaxy/jobs/runners/util/pykube_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/jobs/runners/util/pykube_util.py b/lib/galaxy/jobs/runners/util/pykube_util.py index a86601c324f..0203b9f5046 100644 --- a/lib/galaxy/jobs/runners/util/pykube_util.py +++ b/lib/galaxy/jobs/runners/util/pykube_util.py @@ -47,7 +47,7 @@ def produce_unique_k8s_job_name(app_prefix=None, instance_id=None, job_id=None): if app_prefix: job_name += "%s-" % app_prefix - if instance_id and instance_id > 0: + if instance_id and len(instance_id) > 0: job_name += "%s-" % instance_id return job_name + job_id From b2cd5ba8d052d22ef29b3725e8d46052a3b5f3a0 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 10 Jul 2019 15:02:59 +0200 Subject: [PATCH 3/5] Add k8s_walltime_limit to job_conf.xml.sample_advanced --- lib/galaxy/config/sample/job_conf.xml.sample_advanced | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/galaxy/config/sample/job_conf.xml.sample_advanced b/lib/galaxy/config/sample/job_conf.xml.sample_advanced index 471946d0e3a..ebb74e9514d 100644 --- a/lib/galaxy/config/sample/job_conf.xml.sample_advanced +++ b/lib/galaxy/config/sample/job_conf.xml.sample_advanced @@ -216,6 +216,11 @@ zero (no execution) and the stderr/stdout of the k8s job is reported in galaxy (and the galaxy job set to failed) --> + + +