Skip to content

Commit

Permalink
htcondor: allow specifying max runtime and accounting group
Browse files Browse the repository at this point in the history
  • Loading branch information
alintulu committed Oct 9, 2020
1 parent a8d47d2 commit ac37cd5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions docs/openapi.json
Expand Up @@ -57,6 +57,12 @@
"default": {},
"type": "object"
},
"htcondor_accounting_group": {
"type": "string"
},
"htcondor_max_runtime": {
"type": "string"
},
"job_name": {
"type": "string"
},
Expand Down
32 changes: 31 additions & 1 deletion reana_job_controller/htcondorcern_job_manager.py
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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 |"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions reana_job_controller/schemas.py
Expand Up @@ -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)

0 comments on commit ac37cd5

Please sign in to comment.