mirror of
https://gitlab.cs.uni-saarland.de/hpc/cc-condor-sync.git
synced 2024-12-26 13:39:05 +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 = ''
|
apiurl = ''
|
||||||
apikey = ''
|
apikey = ''
|
||||||
headers = {}
|
headers = {}
|
||||||
|
debug = False
|
||||||
|
|
||||||
def __init__(self, config, debug=False):
|
def __init__(self, config, debug=False):
|
||||||
self.config = config
|
self.config = config
|
||||||
@ -32,6 +33,7 @@ class CCApi:
|
|||||||
self.headers = {'accept': 'application/ld+json',
|
self.headers = {'accept': 'application/ld+json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': 'Bearer %s' % self.config['cc-backend']['apikey']}
|
'Authorization': 'Bearer %s' % self.config['cc-backend']['apikey']}
|
||||||
|
self.debug = debug
|
||||||
|
|
||||||
def startJob(self, data):
|
def startJob(self, data):
|
||||||
url = self.apiurl+"jobs/start_job/"
|
url = self.apiurl+"jobs/start_job/"
|
||||||
@ -39,6 +41,9 @@ class CCApi:
|
|||||||
if r.status_code == 201:
|
if r.status_code == 201:
|
||||||
return r.json()
|
return r.json()
|
||||||
elif r.status_code == 422:
|
elif r.status_code == 422:
|
||||||
|
if self.debug:
|
||||||
|
print(data)
|
||||||
|
print(r.status_code, r.content)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print(data)
|
print(data)
|
||||||
@ -365,7 +370,7 @@ class CondorSync:
|
|||||||
# endtime = int(ccjob['startTime']) + 1
|
# endtime = int(ccjob['startTime']) + 1
|
||||||
|
|
||||||
jobstate_map = {4: "cancelled", 5: "completed",
|
jobstate_map = {4: "cancelled", 5: "completed",
|
||||||
9: "failed", 10: "stopped", 12: "stopped"}
|
9: "cancelled", 10: "stopped", 12: "stopped"}
|
||||||
jobstate = jobstate_map[job['TriggerEventTypeNumber']]
|
jobstate = jobstate_map[job['TriggerEventTypeNumber']]
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
@ -374,13 +379,19 @@ class CondorSync:
|
|||||||
'jobState': jobstate
|
'jobState': jobstate
|
||||||
}
|
}
|
||||||
if 'ToE' in job:
|
if 'ToE' in job:
|
||||||
|
if isinstance(job['ToE']['When'], int):
|
||||||
data['stopTime'] = job['ToE']['When']
|
data['stopTime'] = job['ToE']['When']
|
||||||
|
else:
|
||||||
|
data['stopTime'] = int(time.mktime(dateparser.parse(job['ToE']['When']).timetuple()))
|
||||||
else:
|
else:
|
||||||
data['stopTime'] = int(time.mktime(dateparser.parse(job['EventTime']).timetuple()))
|
data['stopTime'] = int(time.mktime(dateparser.parse(job['EventTime']).timetuple()))
|
||||||
|
|
||||||
if 'JobCurrentStartDate' in job:
|
if 'JobCurrentStartDate' in job:
|
||||||
data['startTime'] = job['JobCurrentStartDate']
|
data['startTime'] = job['JobCurrentStartDate']
|
||||||
|
|
||||||
|
if self.debug:
|
||||||
|
print(data)
|
||||||
|
|
||||||
self.ccapi.stopJob(data)
|
self.ccapi.stopJob(data)
|
||||||
|
|
||||||
def _convertNodelist(self, nodelist):
|
def _convertNodelist(self, nodelist):
|
||||||
|
Loading…
Reference in New Issue
Block a user