ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/SchedulerRemoteglidein.py
(Generate patch)

Comparing COMP/CRAB/python/SchedulerRemoteglidein.py (file contents):
Revision 1.4 by belforte, Tue Oct 2 14:56:52 2012 UTC vs.
Revision 1.15 by belforte, Thu Feb 7 16:57:51 2013 UTC

# Line 40 | Line 40 | class SchedulerRemoteglidein(SchedulerGr
40  
41          self.environment_unique_identifier = None
42          self.submissionDay = time.strftime("%y%m%d",time.localtime())
43 <
43 >        
44          return
45  
46  
# Line 48 | Line 48 | class SchedulerRemoteglidein(SchedulerGr
48          """
49          Configure the scheduler with the config settings from the user
50          """
51 <        
51 >  
52 >        # this line needs to be before the call to SchedulerGrid.configure
53 >        # because that calls SchedulerRemoteglidin in turn and
54 >        # sshControlPersist needs to be defined then :-(
55 >        self.sshControlPersist =  cfg_params.get('USER.ssh_control_persist','3600')
56 >        if self.sshControlPersist.lower() == "no" or \
57 >                self.sshControlPersist.lower() == "yes" or \
58 >                self.sshControlPersist.isdigit() :
59 >            pass
60 >        else:
61 >            msg = "Error: invalid value '%s' for USER.ssh_control_persist " % \
62 >                self.sshControlPersist
63 >            raise CrabException(msg)
64 >
65          SchedulerGrid.configure(self, cfg_params)
66  
67          self.proxyValid=0
68 <        self.dontCheckProxy=int(cfg_params.get("GRID.dont_check_proxy",0))
68 >        self.dontCheckProxy=int(cfg_params.get("GRID.dont_check_proxy",'0'))
69          self.space_token = cfg_params.get("USER.space_token",None)
70          self.proxyServer= 'myproxy.cern.ch'
71          self.group = cfg_params.get("GRID.group", None)
72          self.role = cfg_params.get("GRID.role", None)
73          self.VO = cfg_params.get('GRID.virtual_organization','cms')
74 +        self.allowOverflow = cfg_params.get('GRID.allow_overflow', '1')
75 +        self.max_rss = cfg_params.get('GRID.max_rss','2000')
76  
77          self.checkProxy()
78  
# Line 81 | Line 96 | class SchedulerRemoteglidein(SchedulerGr
96              msg+="\n Use GRID.se_white_list and/or GRID.se_black_list instead"
97              raise CrabException(msg)
98  
99 +
100 +        # make sure proxy FQAN has not changed since last time
101 +        command =  "voms-proxy-info -identity -fqan 2>/dev/null"
102 +        command += " | head -2"
103 +        identity = runCommand(command)
104 +        idfile = common.work_space.shareDir() + "GridIdentity"
105 +        if os.access(idfile, os.F_OK) :
106 +            # identity file exists from previous commands
107 +            f=open(idfile, 'r')
108 +            idFromFile=f.read()
109 +            f.close()
110 +        else :
111 +            # create it
112 +            f=open(idfile, 'w')
113 +            f.write(identity)
114 +            f.close()
115 +            idFromFile = identity
116 +
117 +        if identity != idFromFile:
118 +            msg =  "Wrong Grid Credentials:\n%s" % identity
119 +            msg += "\nMake sure you have "
120 +            msg += " DN, FQAN =\n%s" % idFromFile
121 +            raise CrabException(msg)
122 +
123          return
124      
125      def userName(self):
# Line 99 | Line 138 | class SchedulerRemoteglidein(SchedulerGr
138          by $CRABPYTHON/Scheduler.py
139          """
140  
141 < #SB paste from crab ScheduerGlidein
141 > #SB paste from crab SchedulerGlidein
142  
143          jobParams = ""
144  
# Line 126 | Line 165 | class SchedulerRemoteglidein(SchedulerGr
165          jobParams += '+DESIRED_CMSScramArch ="' +scramArch+'";'
166          
167          myscheddName = self.remoteHost
168 +
169          jobParams += '+Glidein_MonitorID = "https://'+ myscheddName + \
170                       '//' + self.submissionDay + '//$(Cluster).$(Process)"; '
171  
172          if (self.EDG_clock_time):
173 <            jobParams += '+MaxWallTimeMins = '+self.EDG_clock_time+'; '
173 >            glideinTime = "%d" % (int(self.EDG_clock_time)+5) # 5 min to wrapup
174 >            jobParams += '+MaxWallTimeMins = '+ glideinTime + '; '
175          else:
176 <            jobParams += '+MaxWallTimeMins = %d; ' % (60*24)
176 >            jobParams += '+MaxWallTimeMins = %d; ' % (60*22 - 5) # 22h default in glidein, 5min to wrap
177  
178 <        common._db.updateTask_({'jobType':jobParams})
178 >        if self.max_rss :
179 >            jobParams += 'request_memory = '+self.max_rss+';'
180 >
181 >        if self.allowOverflow == "0":
182 >            jobParams += '+CMS_ALLOW_OVERFLOW = False; '
183  
184 +        if self.EDG_addJdlParam:
185 +            if self.EDG_addJdlParam[-1] == '':
186 +                self.EDG_addJdlParam = self.EDG_addJdlParam[:-1]
187 +            for p in self.EDG_addJdlParam:
188 +                jobParams += p.strip()+';\n'
189 +
190 +        common._db.updateTask_({'jobType':jobParams})
191  
192          return jobParams
193  
# Line 145 | Line 197 | class SchedulerRemoteglidein(SchedulerGr
197          Return dictionary with specific parameters, to use with real scheduler
198          is called when scheduler is initialized in Boss, i.e. at each crab command
199          """
200 <        #SB this method is used to pass directory names to Boss Scheduler
200 >        #SB this method is used to pass informatinos to Boss Scheduler
201          # via params dictionary
202  
203          jobDir = common.work_space.jobDir()
# Line 155 | Line 207 | class SchedulerRemoteglidein(SchedulerGr
207          params = {'shareDir':shareDir,
208                    'jobDir':jobDir,
209                    'taskDir':taskDir,
210 <                  'submissionDay':self.submissionDay}
210 >                  'submissionDay':self.submissionDay,
211 >                  'sshControlPersist':self.sshControlPersist}
212  
213          return params
214  
# Line 200 | Line 253 | class SchedulerRemoteglidein(SchedulerGr
253  
254          txt += 'func_exit() { \n'
255          txt += self.wsExitFunc_common()
203
204        txt += '    tar zcvf ${out_files}.tgz  ${final_list}\n'
205        txt += '    tmp_size=`ls -gGrta ${out_files}.tgz | awk \'{ print $3 }\'`\n'
206        txt += '    rm ${out_files}.tgz\n'
207        txt += '    size=`expr $tmp_size`\n'
208        txt += '    echo "Total Output dimension: $size"\n'
209        txt += '    limit='+str(self.OSBsize) +' \n'
210        txt += '    echo "WARNING: output files size limit is set to: $limit"\n'
211        txt += '    if [ "$limit" -lt "$size" ]; then\n'
212        txt += '        exceed=1\n'
213        txt += '        job_exit_code=70000\n'
214        txt += '        echo "Output Sanbox too big. Produced output is lost "\n'
215        txt += '    else\n'
216        txt += '        exceed=0\n'
217        txt += '        echo "Total Output dimension $size is fine."\n'
218        txt += '    fi\n'
219
220        txt += '    echo "JOB_EXIT_STATUS = $job_exit_code"\n'
221        txt += '    echo "JobExitCode=$job_exit_code" >> $RUNTIME_AREA/$repo\n'
222        txt += '    dumpStatus $RUNTIME_AREA/$repo\n'
223        txt += '    if [ $exceed -ne 1 ]; then\n'
224        txt += '        tar zcvf ${out_files}.tgz  ${final_list}\n'
225        txt += '    else\n'
226        txt += '        tar zcvf ${out_files}.tgz CMSSW_${NJob}.stdout CMSSW_${NJob}.stderr\n'
227        txt += '    fi\n'
228        txt += '    python $RUNTIME_AREA/fillCrabFjr.py $RUNTIME_AREA/crab_fjr_$NJob.xml --errorcode $job_exit_code \n'
229
256          txt += '    exit $job_exit_code\n'
257          txt += '}\n'
258  
# Line 254 | Line 280 | class SchedulerRemoteglidein(SchedulerGr
280              remoteUserHost=str(task['serverName'])
281              common.logger.info("serverName from Task DB is %s" %
282                                 remoteUserHost)
257            if '@' in remoteUserHost:
258                remoteHost = remoteUserHost.split('@')[1]
259            else:
260                remoteHost = remoteUserHost
283          else:
284              if self.cfg_params.has_key('CRAB.submit_host'):
285                  # get a remote submission host from crab config file
286                  srvCfg=ServerConfig(self.cfg_params['CRAB.submit_host']).config()
287 <                remoteHost=srvCfg['serverName']
288 <                common.logger.info("remotehost from crab.cfg = %s" % remoteHost)
287 >                remoteUserHost=srvCfg['serverName']
288 >                common.logger.info("remotehost from crab.cfg = %s" % remoteUserHost)
289              else:
290                  # pick from Available Servers List
291                  srvCfg=ServerConfig('default').config()
292 <                remoteHost = srvCfg['serverName']
293 <                common.logger.info("remotehost from Avail.List = %s" % remoteHost)
292 >                remoteUserHost = srvCfg['serverName']
293 >                common.logger.info("remotehost from Avail.List = %s" % remoteUserHost)
294  
295 <            if not remoteHost:
295 >            if not remoteUserHost:
296                  raise CrabException('FATAL ERROR: remoteHost not defined')
275            
276            #common.logger.info("try to find out username for remote Host via uberftp ...")
277            #command="uberftp %s pwd|grep User|awk '{print $3}'" % remoteHost
278            #(status, output) = commands.getstatusoutput(command)
279            #if status == 0:
280            #    remoteUser = output
281            #    common.logger.info("remoteUser set to %s" % remoteUser)
282            #    if remoteUser==None:
283            #        raise CrabException('FATAL ERROR: REMOTE USER not defined')
297  
298 <            #remoteUserHost = remoteUser + '@' + remoteHost
299 <            remoteUserHost = remoteHost
298 >        if '@' in remoteUserHost:
299 >            remoteHost = remoteUserHost.split('@')[1]
300 >        else:
301 >            remoteHost = remoteUserHost
302  
303          common._db.updateTask_({'serverName':remoteUserHost})
304  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines