mirror of
https://gitlab.cs.uni-saarland.de/hpc/cc-condor-sync.git
synced 2024-12-25 13:09:06 +01:00
Handle held / requeued jobs.
Requires cc-backend patch proposed in: https://github.com/ClusterCockpit/cc-backend/issues/30 (Upstream assumes startTime to be non-unique if they happened in the same 24hrs).
This commit is contained in:
parent
21cdece420
commit
9e96f65977
@ -24,6 +24,7 @@ class CCApi:
|
||||
apiurl = ''
|
||||
apikey = ''
|
||||
headers = {}
|
||||
debug = False
|
||||
|
||||
def __init__(self, config, debug=False):
|
||||
self.config = config
|
||||
@ -32,6 +33,7 @@ class CCApi:
|
||||
self.headers = {'accept': 'application/ld+json',
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer %s' % self.config['cc-backend']['apikey']}
|
||||
self.debug = debug
|
||||
|
||||
def startJob(self, data):
|
||||
url = self.apiurl+"jobs/start_job/"
|
||||
@ -39,6 +41,9 @@ class CCApi:
|
||||
if r.status_code == 201:
|
||||
return r.json()
|
||||
elif r.status_code == 422:
|
||||
if self.debug:
|
||||
print(data)
|
||||
print(r.status_code, r.content)
|
||||
return False
|
||||
else:
|
||||
print(data)
|
||||
@ -365,7 +370,7 @@ class CondorSync:
|
||||
# endtime = int(ccjob['startTime']) + 1
|
||||
|
||||
jobstate_map = {4: "cancelled", 5: "completed",
|
||||
9: "failed", 10: "stopped", 12: "stopped"}
|
||||
9: "cancelled", 10: "stopped", 12: "stopped"}
|
||||
jobstate = jobstate_map[job['TriggerEventTypeNumber']]
|
||||
|
||||
data = {
|
||||
@ -374,13 +379,19 @@ class CondorSync:
|
||||
'jobState': jobstate
|
||||
}
|
||||
if 'ToE' in job:
|
||||
data['stopTime'] = job['ToE']['When']
|
||||
if isinstance(job['ToE']['When'], int):
|
||||
data['stopTime'] = job['ToE']['When']
|
||||
else:
|
||||
data['stopTime'] = int(time.mktime(dateparser.parse(job['ToE']['When']).timetuple()))
|
||||
else:
|
||||
data['stopTime'] = int(time.mktime(dateparser.parse(job['EventTime']).timetuple()))
|
||||
|
||||
if 'JobCurrentStartDate' in job:
|
||||
data['startTime'] = job['JobCurrentStartDate']
|
||||
|
||||
if self.debug:
|
||||
print(data)
|
||||
|
||||
self.ccapi.stopJob(data)
|
||||
|
||||
def _convertNodelist(self, nodelist):
|
||||
|
Loading…
Reference in New Issue
Block a user