diff --git a/CHANGES.rst b/CHANGES.rst index 4d8fc41f..94302d61 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,7 @@ Changes Version master (UNRELEASED) --------------------------- +- Allows htcondor_max_runtime and htcondor_accounting_group to be specified for HTC jobs. - Uses python3.8 - Pins all Python dependencies allowing to easily rebuild component images at later times. - Adds VOMS proxy support as a new authentication method. diff --git a/docs/openapi.json b/docs/openapi.json index 5ef100de..6f065c19 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -57,6 +57,12 @@ "default": {}, "type": "object" }, + "htcondor_accounting_group": { + "type": "string" + }, + "htcondor_max_runtime": { + "type": "string" + }, "job_name": { "type": "string" }, diff --git a/reana_job_controller/htcondorcern_job_manager.py b/reana_job_controller/htcondorcern_job_manager.py index ffaf0599..76102833 100644 --- a/reana_job_controller/htcondorcern_job_manager.py +++ b/reana_job_controller/htcondorcern_job_manager.py @@ -50,6 +50,8 @@ def __init__( kerberos=False, kubernetes_uid=None, unpacked_img=False, + htcondor_max_runtime=None, + htcondor_accounting_group=None, ): """Instanciate HTCondor job manager. @@ -73,6 +75,10 @@ def __init__( :type job_name: str :unpacked_img: if unpacked_img should be used :type unpacked_img: bool + :param htcondor_max_runtime: Maximum runtime of a HTCondor job. + :type htcondor_max_runtime: str + :param htcondor_accounting_group: Accounting group of a HTCondor job. + :type htcondor_accounting_group: str """ super(HTCondorJobManagerCERN, self).__init__( docker_img=docker_img, @@ -88,6 +94,8 @@ def __init__( self.shared_file_system = shared_file_system self.workflow = self._get_workflow() self.unpacked_img = unpacked_img + self.htcondor_max_runtime = htcondor_max_runtime + self.htcondor_accounting_group = htcondor_accounting_group # We need to import the htcondor package later during runtime after the Kerberos environment is fully initialised. # Without a valid Kerberos ticket, importing will exit with "ERROR: Unauthorized 401 - do you have authentication tokens? Error "/usr/bin/myschedd.sh |" @@ -129,7 +137,22 @@ def execute(self): job_ad["TransferInput"] = self._get_input_files() job_ad["TransferOutput"] = "." job_ad["PeriodicRelease"] = classad.ExprTree("(HoldReasonCode == 35)") - job_ad["MaxRunTime"] = 3600 + if self.htcondor_max_runtime in ( + "espresso", + "microcentury", + "longlunch", + "workday", + "tomorrow", + "testmatch", + "nextweek", + ): + job_ad["JobFlavour"] = self.htcondor_max_runtime + elif HTCondorJobManagerCERN._is_int(self.htcondor_max_runtime): + job_ad["MaxRunTime"] = int(self.htcondor_max_runtime) + else: + job_ad["MaxRunTime"] = 3600 + if self.htcondor_accounting_group: + job_ad["AccountingGroup"] = self.htcondor_accounting_group future = current_app.htcondor_executor.submit(self._submit, job_ad) clusterid = future.result() return clusterid @@ -308,3 +331,10 @@ def find_job_in_history(backend_job_id): except Exception: # Did not match to any job in the history yet return None + + def _is_int(x): + try: + int(x) + return True + except (TypeError, ValueError): + return False diff --git a/reana_job_controller/schemas.py b/reana_job_controller/schemas.py index 915981de..0c0b6fd6 100644 --- a/reana_job_controller/schemas.py +++ b/reana_job_controller/schemas.py @@ -41,3 +41,5 @@ class JobRequest(Schema): voms_proxy = fields.Bool(required=False) kubernetes_uid = fields.Int(required=False) unpacked_img = fields.Bool(required=False) + htcondor_max_runtime = fields.Str(required=False) + htcondor_accounting_group = fields.Str(required=False)