1 |
ewv |
1.62 |
"""
|
2 |
|
|
CRAB interface to BossLite gLite Scheduler
|
3 |
|
|
"""
|
4 |
|
|
|
5 |
slacapra |
1.71 |
__revision__ = "$Id: SchedulerGlite.py,v 1.70 2009/06/24 21:13:45 spiga Exp $"
|
6 |
|
|
__version__ = "$Revision: 1.70 $"
|
7 |
ewv |
1.62 |
|
8 |
slacapra |
1.31 |
from SchedulerGrid import SchedulerGrid
|
9 |
spiga |
1.2 |
from crab_exceptions import *
|
10 |
|
|
from crab_util import *
|
11 |
fanzago |
1.4 |
from GliteConfig import *
|
12 |
spiga |
1.47 |
import EdgLoggingInfo
|
13 |
spiga |
1.2 |
import common
|
14 |
ewv |
1.65 |
from WMCore.SiteScreening.BlackWhiteListParser import CEBlackWhiteListParser
|
15 |
spiga |
1.2 |
|
16 |
|
|
import os, sys, time
|
17 |
|
|
|
18 |
slacapra |
1.31 |
class SchedulerGlite(SchedulerGrid):
|
19 |
slacapra |
1.33 |
def __init__(self, name="GLITE"):
|
20 |
|
|
SchedulerGrid.__init__(self,name)
|
21 |
slacapra |
1.31 |
|
22 |
fanzago |
1.54 |
self.OSBsize = 55000000
|
23 |
spiga |
1.51 |
|
24 |
slacapra |
1.31 |
def configure(self,cfg_params):
|
25 |
|
|
SchedulerGrid.configure(self, cfg_params)
|
26 |
ewv |
1.61 |
self.environment_unique_identifier = '$GLITE_WMS_JOBID'
|
27 |
slacapra |
1.3 |
|
28 |
spiga |
1.51 |
def realSchedParams(self,cfg_params):
|
29 |
|
|
"""
|
30 |
ewv |
1.61 |
Return dictionary with specific parameters, to use
|
31 |
|
|
with real scheduler
|
32 |
spiga |
1.51 |
"""
|
33 |
|
|
self.rb_param_file=''
|
34 |
spiga |
1.68 |
if (not cfg_params.has_key('GRID.rb')):
|
35 |
|
|
cfg_params['GRID.rb']='CERN'
|
36 |
|
|
self.rb_param_file=common.scheduler.rb_configure(cfg_params.get("GRID.rb"))
|
37 |
|
|
self.wms_service=cfg_params.get("GRID.wms_service",'')
|
38 |
|
|
self.skipWMSAuth=cfg_params.get("GRID.skipwmsauth",1)
|
39 |
spiga |
1.51 |
params = { 'service' : self.wms_service, \
|
40 |
afanfani |
1.55 |
'config' : self.rb_param_file, \
|
41 |
ewv |
1.61 |
'skipWMSAuth' : self.skipWMSAuth
|
42 |
spiga |
1.51 |
}
|
43 |
|
|
return params
|
44 |
ewv |
1.61 |
|
45 |
spiga |
1.51 |
|
46 |
fanzago |
1.4 |
def rb_configure(self, RB):
|
47 |
slacapra |
1.71 |
## 25-Jun-2009 SL: patch to use Cream enabled WMS
|
48 |
|
|
if ( self.cfg_params.get('GRID.use_cream',None) ):
|
49 |
|
|
RB='CREAM'
|
50 |
slacapra |
1.31 |
if not RB: return None
|
51 |
|
|
glite_config = None
|
52 |
|
|
rb_param_file = None
|
53 |
fanzago |
1.4 |
|
54 |
|
|
gliteConfig = GliteConfig(RB)
|
55 |
slacapra |
1.31 |
glite_config = gliteConfig.config()
|
56 |
fanzago |
1.4 |
|
57 |
slacapra |
1.31 |
if (glite_config ):
|
58 |
spiga |
1.40 |
rb_param_file = glite_config
|
59 |
slacapra |
1.31 |
return rb_param_file
|
60 |
fanzago |
1.4 |
|
61 |
spiga |
1.36 |
def ce_list(self):
|
62 |
spiga |
1.2 |
"""
|
63 |
ewv |
1.42 |
Returns string with requirement CE related
|
64 |
spiga |
1.2 |
"""
|
65 |
ewv |
1.65 |
ceParser = CEBlackWhiteListParser(self.EDG_ce_white_list,
|
66 |
slacapra |
1.69 |
self.EDG_ce_black_list, common.logger())
|
67 |
ewv |
1.42 |
req = ''
|
68 |
ewv |
1.65 |
ce_white_list = []
|
69 |
|
|
ce_black_list = []
|
70 |
spiga |
1.2 |
if self.EDG_ce_white_list:
|
71 |
ewv |
1.65 |
ce_white_list = ceParser.whiteList()
|
72 |
slacapra |
1.13 |
tmpCe=[]
|
73 |
|
|
concString = '&&'
|
74 |
|
|
for ce in ce_white_list:
|
75 |
|
|
tmpCe.append('RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId)')
|
76 |
mcinquil |
1.20 |
if len(tmpCe) == 1:
|
77 |
|
|
req += " && (" + concString.join(tmpCe) + ") "
|
78 |
|
|
elif len(tmpCe) > 1:
|
79 |
|
|
firstCE = 0
|
80 |
|
|
for reqTemp in tmpCe:
|
81 |
|
|
if firstCE == 0:
|
82 |
|
|
req += " && ( (" + reqTemp + ") "
|
83 |
|
|
firstCE = 1
|
84 |
|
|
elif firstCE > 0:
|
85 |
|
|
req += " || (" + reqTemp + ") "
|
86 |
|
|
if firstCE > 0:
|
87 |
|
|
req += ") "
|
88 |
ewv |
1.28 |
|
89 |
spiga |
1.2 |
if self.EDG_ce_black_list:
|
90 |
ewv |
1.65 |
ce_black_list = ceParser.blackList()
|
91 |
slacapra |
1.13 |
tmpCe=[]
|
92 |
|
|
concString = '&&'
|
93 |
spiga |
1.2 |
for ce in ce_black_list:
|
94 |
slacapra |
1.13 |
tmpCe.append('(!RegExp("' + string.strip(ce) + '", other.GlueCEUniqueId))')
|
95 |
spiga |
1.36 |
if len(tmpCe): req += " && (" + concString.join(tmpCe) + ") "
|
96 |
|
|
|
97 |
|
|
# requirement added to skip gliteCE
|
98 |
|
|
req += '&& (!RegExp("blah", other.GlueCEUniqueId))'
|
99 |
ewv |
1.66 |
retWL = ','.join(ce_white_list)
|
100 |
|
|
retBL = ','.join(ce_black_list)
|
101 |
|
|
if not retWL:
|
102 |
|
|
retWL = None
|
103 |
|
|
if not retBL:
|
104 |
|
|
retBL = None
|
105 |
spiga |
1.36 |
|
106 |
ewv |
1.66 |
return req, retWL, retBL
|
107 |
spiga |
1.36 |
|
108 |
slacapra |
1.60 |
def se_list(self, dest):
|
109 |
spiga |
1.36 |
"""
|
110 |
ewv |
1.42 |
Returns string with requirement SE related
|
111 |
|
|
"""
|
112 |
slacapra |
1.60 |
hostList=self.findSites_(dest)
|
113 |
spiga |
1.36 |
req=''
|
114 |
|
|
reqtmp=[]
|
115 |
|
|
concString = '||'
|
116 |
|
|
|
117 |
|
|
for arg in hostList:
|
118 |
|
|
reqtmp.append(' Member("'+arg+'" , other.GlueCESEBindGroupSEUniqueID) ')
|
119 |
|
|
|
120 |
|
|
if len(reqtmp): req += " && (" + concString.join(reqtmp) + ") "
|
121 |
spiga |
1.11 |
|
122 |
spiga |
1.36 |
return req
|
123 |
|
|
|
124 |
|
|
def jdlParam(self):
|
125 |
|
|
"""
|
126 |
ewv |
1.42 |
Returns
|
127 |
|
|
"""
|
128 |
spiga |
1.36 |
req=''
|
129 |
|
|
if self.EDG_addJdlParam:
|
130 |
ewv |
1.42 |
if self.EDG_addJdlParam[-1] == '': self.EDG_addJdlParam= self.EDG_addJdlParam[:-1]
|
131 |
spiga |
1.36 |
for p in self.EDG_addJdlParam:
|
132 |
ewv |
1.61 |
req+=string.strip(p)+';\n'
|
133 |
spiga |
1.36 |
return req
|
134 |
|
|
|
135 |
|
|
def specific_req(self):
|
136 |
|
|
"""
|
137 |
|
|
Returns string with specific requirements
|
138 |
ewv |
1.42 |
"""
|
139 |
spiga |
1.36 |
req=''
|
140 |
spiga |
1.2 |
if self.EDG_clock_time:
|
141 |
slacapra |
1.13 |
if (not req == ' '): req = req + ' && '
|
142 |
|
|
req = req + 'other.GlueCEPolicyMaxWallClockTime>='+self.EDG_clock_time
|
143 |
spiga |
1.2 |
|
144 |
|
|
if self.EDG_cpu_time:
|
145 |
slacapra |
1.13 |
if (not req == ' '): req = req + ' && '
|
146 |
|
|
req = req + ' other.GlueCEPolicyMaxCPUTime>='+self.EDG_cpu_time
|
147 |
ewv |
1.42 |
|
148 |
spiga |
1.36 |
return req
|
149 |
ewv |
1.28 |
|
150 |
spiga |
1.39 |
def sched_parameter(self,i,task):
|
151 |
|
|
"""
|
152 |
|
|
Returns string with requirements and scheduler-specific parameters
|
153 |
|
|
"""
|
154 |
ewv |
1.61 |
dest= task.jobs[i-1]['dlsDestination']
|
155 |
spiga |
1.39 |
|
156 |
|
|
req=''
|
157 |
|
|
req +=task['jobType']
|
158 |
|
|
|
159 |
|
|
sched_param=''
|
160 |
slacapra |
1.60 |
sched_param+='Requirements = ' + req +self.specific_req() + self.se_list(dest) +\
|
161 |
ewv |
1.61 |
self.ce_list()[0] +';\n'
|
162 |
|
|
if self.EDG_addJdlParam: sched_param+=self.jdlParam()
|
163 |
spiga |
1.39 |
sched_param+='MyProxyServer = "' + self.proxyServer + '";\n'
|
164 |
|
|
sched_param+='VirtualOrganisation = "' + self.VO + '";\n'
|
165 |
|
|
sched_param+='RetryCount = '+str(self.EDG_retry_count)+';\n'
|
166 |
|
|
sched_param+='ShallowRetryCount = '+str(self.EDG_shallow_retry_count)+';\n'
|
167 |
|
|
|
168 |
|
|
return sched_param
|
169 |
ewv |
1.42 |
|
170 |
spiga |
1.47 |
def decodeLogInfo(self, file):
|
171 |
|
|
"""
|
172 |
|
|
Parse logging info file and return main info
|
173 |
|
|
"""
|
174 |
|
|
loggingInfo = EdgLoggingInfo.EdgLoggingInfo()
|
175 |
|
|
reason = loggingInfo.decodeReason(file)
|
176 |
|
|
return reason
|
177 |
|
|
|
178 |
slacapra |
1.60 |
def findSites_(self, sites):
|
179 |
spiga |
1.39 |
itr4 =[]
|
180 |
|
|
if len(sites)>0 and sites[0]=="":
|
181 |
|
|
return itr4
|
182 |
|
|
if sites != [""]:
|
183 |
slacapra |
1.60 |
replicas = self.blackWhiteListParser.checkBlackList(sites)
|
184 |
spiga |
1.39 |
if len(replicas)!=0:
|
185 |
slacapra |
1.60 |
replicas = self.blackWhiteListParser.checkWhiteList(replicas)
|
186 |
ewv |
1.42 |
|
187 |
spiga |
1.39 |
itr4 = replicas
|
188 |
|
|
return itr4
|
189 |
|
|
|
190 |
spiga |
1.70 |
def delegateProxy(self):
|
191 |
|
|
self.boss().delegateProxy()
|
192 |
|
|
return
|
193 |
ewv |
1.61 |
|
194 |
spiga |
1.51 |
def wsExitFunc(self):
|
195 |
|
|
"""
|
196 |
|
|
"""
|
197 |
|
|
txt = '\n'
|
198 |
|
|
|
199 |
|
|
txt += '#\n'
|
200 |
|
|
txt += '# EXECUTE THIS FUNCTION BEFORE EXIT \n'
|
201 |
|
|
txt += '#\n\n'
|
202 |
|
|
|
203 |
|
|
txt += 'func_exit() { \n'
|
204 |
|
|
txt += self.wsExitFunc_common()
|
205 |
|
|
### specific Glite check for OSB
|
206 |
|
|
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n'
|
207 |
|
|
txt += ' tmp_size=`ls -gGrta ${out_files}.tgz | awk \'{ print $3 }\'`\n'
|
208 |
ewv |
1.61 |
txt += ' rm ${out_files}.tgz\n'
|
209 |
spiga |
1.51 |
txt += ' size=`expr $tmp_size`\n'
|
210 |
|
|
txt += ' echo "Total Output dimension: $size"\n'
|
211 |
ewv |
1.61 |
txt += ' limit='+str(self.OSBsize) +' \n'
|
212 |
spiga |
1.51 |
txt += ' echo "WARNING: output files size limit is set to: $limit"\n'
|
213 |
spiga |
1.53 |
txt += ' if [ "$limit" -lt "$size" ]; then\n'
|
214 |
spiga |
1.51 |
txt += ' exceed=1\n'
|
215 |
|
|
txt += ' job_exit_code=70000\n'
|
216 |
|
|
txt += ' echo "Output Sanbox too big. Produced output is lost "\n'
|
217 |
|
|
txt += ' else\n'
|
218 |
|
|
txt += ' exceed=0\n'
|
219 |
spiga |
1.53 |
txt += ' echo "Total Output dimension $size is fine."\n'
|
220 |
spiga |
1.51 |
txt += ' fi\n'
|
221 |
|
|
|
222 |
|
|
txt += ' echo "JOB_EXIT_STATUS = $job_exit_code"\n'
|
223 |
|
|
txt += ' echo "JobExitCode=$job_exit_code" >> $RUNTIME_AREA/$repo\n'
|
224 |
|
|
txt += ' dumpStatus $RUNTIME_AREA/$repo\n'
|
225 |
|
|
txt += ' if [ $exceed -ne 1 ]; then\n'
|
226 |
|
|
txt += ' tar zcvf ${out_files}.tgz ${final_list}\n'
|
227 |
|
|
txt += ' else\n'
|
228 |
|
|
txt += ' tar zcvf ${out_files}.tgz CMSSW_${NJob}.stdout CMSSW_${NJob}.stderr\n'
|
229 |
|
|
txt += ' fi\n'
|
230 |
|
|
txt += ' exit $job_exit_code\n'
|
231 |
|
|
|
232 |
|
|
txt += '}\n'
|
233 |
|
|
return txt
|