1 |
slacapra |
1.1 |
from Actor import *
|
2 |
gutsche |
1.6 |
from crab_util import *
|
3 |
gutsche |
1.4 |
import EdgLoggingInfo
|
4 |
gutsche |
1.6 |
import CondorGLoggingInfo
|
5 |
slacapra |
1.1 |
import common
|
6 |
|
|
import string, os
|
7 |
|
|
|
8 |
|
|
class PostMortem(Actor):
|
9 |
slacapra |
1.8 |
def __init__(self, cfg_params, nj_list):
|
10 |
slacapra |
1.1 |
self.cfg_params = cfg_params
|
11 |
|
|
self.nj_list = nj_list
|
12 |
|
|
return
|
13 |
|
|
|
14 |
|
|
def run(self):
|
15 |
|
|
"""
|
16 |
|
|
The main method of the class.
|
17 |
|
|
"""
|
18 |
|
|
common.logger.debug(5, "PostMortem::run() called")
|
19 |
|
|
|
20 |
|
|
if len(self.nj_list)==0:
|
21 |
|
|
common.logger.debug(5, "No jobs to check")
|
22 |
|
|
return
|
23 |
|
|
|
24 |
|
|
# run a list-match on first job
|
25 |
|
|
for nj in self.nj_list:
|
26 |
slacapra |
1.5 |
id = common.scheduler.boss_SID(nj)
|
27 |
spiga |
1.2 |
out = common.scheduler.loggingInfo(id)
|
28 |
fanzago |
1.3 |
job = common.job_list[nj-1]
|
29 |
gutsche |
1.7 |
jobnum_str = '%06d' % (int(nj))
|
30 |
|
|
fname = common.work_space.jobDir() + '/' + self.cfg_params['CRAB.jobtype'].upper() + '_' + jobnum_str + '.loggingInfo'
|
31 |
|
|
if os.path.exists(fname):
|
32 |
|
|
common.logger.message('Logging info for job '+str(nj)+' already present in '+fname+' Remove it for update')
|
33 |
slacapra |
1.1 |
continue
|
34 |
gutsche |
1.7 |
jdl = open(fname, 'w')
|
35 |
slacapra |
1.1 |
for line in out: jdl.write(line)
|
36 |
|
|
jdl.close()
|
37 |
gutsche |
1.4 |
|
38 |
gutsche |
1.6 |
reason = ''
|
39 |
|
|
if common.scheduler.boss_scheduler_name == "edg" :
|
40 |
|
|
loggingInfo = EdgLoggingInfo.EdgLoggingInfo()
|
41 |
|
|
reason = loggingInfo.decodeReason(out)
|
42 |
|
|
elif common.scheduler.boss_scheduler_name == "condor_g" :
|
43 |
|
|
loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
|
44 |
|
|
reason = loggingInfo.decodeReason(out)
|
45 |
|
|
else :
|
46 |
|
|
reason = out
|
47 |
gutsche |
1.4 |
|
48 |
gutsche |
1.7 |
common.logger.message('Logging info for job '+str(nj)+': '+reason+'\n written to '+fname)
|
49 |
slacapra |
1.1 |
|
50 |
gutsche |
1.4 |
# ML reporting
|
51 |
|
|
jobId = ''
|
52 |
|
|
if common.scheduler.boss_scheduler_name == 'condor_g':
|
53 |
|
|
# create hash of cfg file
|
54 |
|
|
hash = makeCksum(common.work_space.cfgFileName())
|
55 |
|
|
jobId = str(nj) + '_' + hash + '_' + id
|
56 |
|
|
else:
|
57 |
|
|
jobId = str(nj) + '_' + id
|
58 |
|
|
|
59 |
|
|
params = {'taskId': self.cfg_params['taskId'], 'jobId': jobId, \
|
60 |
|
|
'sid': id,
|
61 |
|
|
'PostMortemCategory': loggingInfo.getCategory(), \
|
62 |
|
|
'PostMortemReason': loggingInfo.getReason()}
|
63 |
|
|
self.cfg_params['apmon'].sendToML(params)
|
64 |
slacapra |
1.1 |
pass
|
65 |
|
|
|
66 |
|
|
return
|
67 |
|
|
|