1 |
ewv |
1.1 |
from SchedulerGrid import SchedulerGrid
|
2 |
|
|
from JobList import JobList
|
3 |
|
|
from crab_logger import Logger
|
4 |
|
|
from crab_exceptions import *
|
5 |
|
|
from crab_util import *
|
6 |
|
|
from osg_bdii import *
|
7 |
|
|
import time
|
8 |
|
|
import common
|
9 |
|
|
import popen2
|
10 |
|
|
import os
|
11 |
|
|
from BlackWhiteListParser import BlackWhiteListParser
|
12 |
|
|
import CondorGLoggingInfo
|
13 |
|
|
|
14 |
|
|
# This class was originally SchedulerCondor_g. For a history of this code, see that file.
|
15 |
|
|
|
16 |
|
|
import pdb # Use while debugging
|
17 |
|
|
|
18 |
ewv |
1.4 |
__revision__ = "$Id: SchedulerCondorCommon.py,v 1.3 2008/04/21 16:08:30 ewv Exp $"
|
19 |
|
|
__version__ = "$Revision: 1.3 $"
|
20 |
ewv |
1.1 |
|
21 |
|
|
class SchedulerCondorCommon(SchedulerGrid):
|
22 |
|
|
def __init__(self,name):
|
23 |
|
|
SchedulerGrid.__init__(self,name)
|
24 |
|
|
|
25 |
|
|
# check for locally running condor scheduler
|
26 |
|
|
cmd = 'ps xau | grep -i condor_schedd | grep -v grep'
|
27 |
|
|
cmd_out = runCommand(cmd)
|
28 |
|
|
if cmd_out == None:
|
29 |
|
|
msg = '[Condor-G Scheduler]: condor_schedd is not running on this machine.\n'
|
30 |
|
|
msg += '[Condor-G Scheduler]: Please use another machine with installed condor and running condor_schedd or change the Scheduler in your crab.cfg.'
|
31 |
|
|
common.logger.debug(2,msg)
|
32 |
|
|
raise CrabException(msg)
|
33 |
|
|
|
34 |
|
|
self.checkExecutableInPath('condor_q')
|
35 |
|
|
self.checkExecutableInPath('condor_submit')
|
36 |
|
|
self.checkExecutableInPath('condor_version')
|
37 |
|
|
|
38 |
|
|
# get version number
|
39 |
|
|
cmd = 'condor_version'
|
40 |
|
|
cmd_out = runCommand(cmd)
|
41 |
|
|
if cmd != None :
|
42 |
|
|
tmp = cmd_out.find('CondorVersion') + 15
|
43 |
|
|
version = cmd_out[tmp:tmp+6].split('.')
|
44 |
|
|
version_master = int(version[0])
|
45 |
|
|
version_major = int(version[1])
|
46 |
|
|
version_minor = int(version[2])
|
47 |
|
|
else :
|
48 |
|
|
msg = '[Condor-G Scheduler]: condor_version was not able to determine the installed condor version.\n'
|
49 |
|
|
msg += '[Condor-G Scheduler]: Please use another machine with properly installed condor or change the Scheduler in your crab.cfg.'
|
50 |
|
|
common.logger.debug(2,msg)
|
51 |
|
|
raise CrabException(msg)
|
52 |
|
|
|
53 |
|
|
self.checkExecutableInPath('condor_config_val')
|
54 |
|
|
self.checkCondorVariablePointsToFile('GRIDMANAGER')
|
55 |
|
|
self.checkCondorVariablePointsToFile('GT2_GAHP',alternate_name='GAHP')
|
56 |
|
|
self.checkCondorVariablePointsToFile('GRID_MONITOR')
|
57 |
|
|
self.checkCondorVariableIsTrue('ENABLE_GRID_MONITOR')
|
58 |
|
|
|
59 |
|
|
max_submit = self.queryCondorVariable('GRIDMANAGER_MAX_SUBMITTED_JOBS_PER_RESOURCE',100).strip()
|
60 |
|
|
max_pending = self.queryCondorVariable('GRIDMANAGER_MAX_PENDING_SUBMITS_PER_RESOURCE','Unlimited').strip()
|
61 |
|
|
|
62 |
|
|
msg = '[Condor-G Scheduler]\n'
|
63 |
|
|
msg += 'Maximal number of jobs submitted to the grid : GRIDMANAGER_MAX_SUBMITTED_JOBS_PER_RESOURCE = '+max_submit+'\n'
|
64 |
|
|
msg += 'Maximal number of parallel submits to the grid : GRIDMANAGER_MAX_PENDING_SUBMITS_PER_RESOURCE = '+max_pending+'\n'
|
65 |
|
|
msg += 'Ask the administrator of your local condor installation to increase these variables to enable more jobs to be executed on the grid in parallel.\n'
|
66 |
|
|
common.logger.debug(2,msg)
|
67 |
|
|
|
68 |
|
|
# create hash
|
69 |
|
|
self.hash = makeCksum(common.work_space.cfgFileName())
|
70 |
|
|
|
71 |
|
|
return
|
72 |
|
|
|
73 |
|
|
def checkExecutableInPath(self, name):
|
74 |
|
|
# check if executable is in PATH
|
75 |
|
|
cmd = 'which '+name
|
76 |
|
|
cmd_out = runCommand(cmd)
|
77 |
|
|
if cmd_out == None:
|
78 |
|
|
msg = '[Condor-G Scheduler]: '+name+' is not in the $PATH on this machine.\n'
|
79 |
|
|
msg += '[Condor-G Scheduler]: Please use another machine with installed condor or change the Scheduler in your crab.cfg.'
|
80 |
|
|
common.logger.debug(2,msg)
|
81 |
|
|
raise CrabException(msg)
|
82 |
|
|
|
83 |
|
|
def checkCondorVariablePointsToFile(self, name, alternate_name=None):
|
84 |
|
|
## check for condor variable
|
85 |
|
|
cmd = 'condor_config_val '+name
|
86 |
|
|
cmd_out = runCommand(cmd)
|
87 |
|
|
if alternate_name and not cmd_out:
|
88 |
|
|
cmd = 'condor_config_val '+alternate_name
|
89 |
|
|
cmd_out = runCommand(cmd)
|
90 |
|
|
if cmd_out:
|
91 |
|
|
cmd_out = string.strip(cmd_out)
|
92 |
|
|
if not cmd_out or not os.path.isfile(cmd_out) :
|
93 |
|
|
msg = '[Condor-G Scheduler]: the variable '+name+' is not properly set for the condor installation on this machine.\n'
|
94 |
|
|
msg += '[Condor-G Scheduler]: Please ask the administrator of the local condor installation to set the variable '+name+' properly, ' + \
|
95 |
|
|
'use another machine with properly installed condor or change the Scheduler in your crab.cfg.'
|
96 |
|
|
common.logger.debug(2,msg)
|
97 |
|
|
raise CrabException(msg)
|
98 |
|
|
|
99 |
|
|
def checkCondorVariableIsTrue(self, name):
|
100 |
|
|
## check for condor variable
|
101 |
|
|
cmd = 'condor_config_val '+name
|
102 |
|
|
cmd_out = runCommand(cmd)
|
103 |
|
|
if cmd_out == 'TRUE' :
|
104 |
|
|
msg = '[Condor-G Scheduler]: the variable '+name+' is not set to true for the condor installation on this machine.\n'
|
105 |
|
|
msg += '[Condor-G Scheduler]: Please ask the administrator of the local condor installation to set the variable '+name+' to true,',
|
106 |
|
|
'use another machine with properly installed condor or change the Scheduler in your crab.cfg.'
|
107 |
|
|
common.logger.debug(2,msg)
|
108 |
|
|
raise CrabException(msg)
|
109 |
|
|
|
110 |
|
|
def queryCondorVariable(self, name, default):
|
111 |
|
|
## check for condor variable
|
112 |
|
|
cmd = 'condor_config_val '+name
|
113 |
|
|
out = popen2.Popen3(cmd,1)
|
114 |
|
|
exit_code = out.wait()
|
115 |
|
|
cmd_out = out.fromchild.readline().strip()
|
116 |
|
|
if exit_code != 0 :
|
117 |
|
|
cmd_out = str(default)
|
118 |
|
|
|
119 |
|
|
return cmd_out
|
120 |
|
|
|
121 |
|
|
def configure(self, cfg_params):
|
122 |
|
|
SchedulerGrid.configure(self,cfg_params)
|
123 |
|
|
|
124 |
|
|
# init BlackWhiteListParser
|
125 |
|
|
#self.blackWhiteListParser = BlackWhiteListParser(cfg_params)
|
126 |
|
|
|
127 |
|
|
try:
|
128 |
|
|
self.GLOBUS_RSL = cfg_params['CONDORG.globus_rsl']
|
129 |
|
|
except KeyError:
|
130 |
|
|
self.GLOBUS_RSL = ''
|
131 |
|
|
|
132 |
|
|
# Provide an override for the batchsystem that condor_g specifies as a grid resource.
|
133 |
|
|
# this is to handle the case where the site supports several batchsystem but bdii
|
134 |
|
|
# only allows a site to public one.
|
135 |
|
|
try:
|
136 |
|
|
self.batchsystem = cfg_params['CONDORG.batchsystem']
|
137 |
|
|
msg = '[Condor-G Scheduler]: batchsystem overide specified in your crab.cfg'
|
138 |
|
|
common.logger.debug(2,msg)
|
139 |
|
|
except KeyError:
|
140 |
|
|
self.batchsystem = ''
|
141 |
|
|
|
142 |
|
|
try:
|
143 |
|
|
self.UseGT4 = cfg_params['USER.use_gt_4'];
|
144 |
|
|
except KeyError:
|
145 |
|
|
self.UseGT4 = 0;
|
146 |
|
|
|
147 |
|
|
# added here because checklistmatch is not used
|
148 |
|
|
self.checkProxy()
|
149 |
|
|
self.environment_unique_identifier = 'GLOBUS_GRAM_JOB_CONTACT'
|
150 |
ewv |
1.4 |
self.datasetPath = ''
|
151 |
ewv |
1.1 |
|
152 |
|
|
try:
|
153 |
|
|
tmp = cfg_params['CMSSW.datasetpath']
|
154 |
|
|
if string.lower(tmp)=='none':
|
155 |
|
|
self.datasetPath = None
|
156 |
|
|
self.selectNoInput = 1
|
157 |
|
|
else:
|
158 |
|
|
self.datasetPath = tmp
|
159 |
|
|
self.selectNoInput = 0
|
160 |
|
|
except KeyError:
|
161 |
|
|
msg = "Error: datasetpath not defined "
|
162 |
|
|
raise CrabException(msg)
|
163 |
|
|
|
164 |
|
|
return
|
165 |
|
|
|
166 |
|
|
def sched_parameter(self,i,task):
|
167 |
|
|
"""
|
168 |
|
|
Returns scheduler-specific parameters
|
169 |
|
|
"""
|
170 |
|
|
jobParams = ''
|
171 |
|
|
globusRSL = self.GLOBUS_RSL
|
172 |
|
|
if (self.EDG_clock_time):
|
173 |
|
|
globusRSL += '(maxWalltime='+self.EDG_clock_time+')'
|
174 |
|
|
if (globusRSL != ''):
|
175 |
|
|
jobParams += 'globusrsl = ' + globusRSL + '; '
|
176 |
|
|
|
177 |
|
|
return jobParams
|
178 |
|
|
|
179 |
|
|
def decodeLogInfo(self, file):
|
180 |
|
|
"""
|
181 |
|
|
Parse logging info file and return main info
|
182 |
|
|
"""
|
183 |
|
|
loggingInfo = CondorGLoggingInfo.CondorGLoggingInfo()
|
184 |
|
|
reason = loggingInfo.decodeReason(file)
|
185 |
|
|
return reason
|
186 |
|
|
|
187 |
|
|
def wsSetupEnvironment(self):
|
188 |
|
|
"""
|
189 |
|
|
Returns part of a job script which does scheduler-specific work.
|
190 |
|
|
"""
|
191 |
|
|
txt = SchedulerGrid.wsSetupEnvironment(self)
|
192 |
|
|
|
193 |
|
|
if int(self.copy_data) == 1:
|
194 |
|
|
if self.SE:
|
195 |
|
|
txt += 'export SE='+self.SE+'\n'
|
196 |
|
|
txt += 'echo "SE = $SE"\n'
|
197 |
|
|
if self.SE_PATH:
|
198 |
|
|
if self.SE_PATH[-1] != '/':
|
199 |
|
|
self.SE_PATH = self.SE_PATH + '/'
|
200 |
|
|
txt += 'export SE_PATH='+self.SE_PATH+'\n'
|
201 |
|
|
txt += 'echo "SE_PATH = $SE_PATH"\n'
|
202 |
|
|
|
203 |
|
|
txt += 'export VO='+self.VO+'\n'
|
204 |
|
|
txt += 'CE=${args[3]}\n'
|
205 |
|
|
txt += 'echo "CE = $CE"\n'
|
206 |
|
|
return txt
|
207 |
|
|
|
208 |
|
|
def wsCopyInput(self):
|
209 |
|
|
"""
|
210 |
|
|
Copy input data from SE to WN
|
211 |
|
|
"""
|
212 |
|
|
txt = '\n'
|
213 |
|
|
return txt
|
214 |
|
|
|
215 |
|
|
def listMatch(self, nj):
|
216 |
|
|
"""
|
217 |
|
|
Check the compatibility of available resources
|
218 |
|
|
"""
|
219 |
|
|
#self.checkProxy()
|
220 |
slacapra |
1.2 |
return [""]
|
221 |
ewv |
1.1 |
|
222 |
|
|
def userName(self):
|
223 |
|
|
""" return the user name """
|
224 |
|
|
self.checkProxy()
|
225 |
|
|
return runCommand("voms-proxy-info -identity")
|
226 |
|
|
|
227 |
|
|
def ce_list(self):
|
228 |
|
|
"""
|
229 |
|
|
Returns string with requirement CE related, dummy for now
|
230 |
|
|
"""
|
231 |
|
|
req = ''
|
232 |
|
|
|
233 |
|
|
return req,self.EDG_ce_white_list,self.EDG_ce_black_list
|