Skip to content

Commit

Permalink
Change xquery to query 8613 (#8615)
Browse files Browse the repository at this point in the history
* use schedd.query() instead of schedd.xquery(). Fix #8613

* cleanup reporting of webdir in AdjustSites
  • Loading branch information
belforte authored Aug 12, 2024
1 parent 50c9d82 commit 43208f8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
21 changes: 3 additions & 18 deletions scripts/AdjustSites.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,28 +320,13 @@ def saveProxiedWebdir(crabserver, ad):
webDir_adName = 'CRAB_WebDirURL'
ad[webDir_adName] = ad['CRAB_localWebDirURL']
proxied_webDir = getProxiedWebDir(crabserver=crabserver, task=task, logFunction=printLog)
if proxied_webDir: # Prefer the proxied webDir to the non-proxied one
ad[webDir_adName] = str(proxied_webDir)

if webDir_adName in ad:
# This condor_edit is required because in the REST interface we look for the webdir if the DB upload failed (or in general if we use the "old logic")
# See https://github.com/dmwm/CRABServer/blob/3.3.1507.rc8/src/python/CRABInterface/HTCondorDataWorkflow.py#L398
dagJobId = '%d.%d' % (ad['ClusterId'], ad['ProcId'])
try:
htcondor.Schedd().edit([dagJobId], webDir_adName, '{0}'.format(ad.lookup(webDir_adName)))
except RuntimeError as reerror:
printLog(str(reerror))

# We need to use a file to communicate this to the prejob. I tried to read the corresponding ClassAd from the preJob like:
# htcondor.Schedd().xquery(requirements="ClusterId == %d && ProcId == %d" % (self.task_ad['ClusterId'], self.task_ad['ProcId']), projection=[webDir_adName]).next().get(webDir_adName)
# but it is too heavy of an operation with HTCondor v8.8.3
if proxied_webDir:
# Use a file to communicate webDir to the prejob
with open("webdir", "w", encoding='utf-8') as fd:
fd.write(ad[webDir_adName])
fd.write(proxied_webDir)
else:
printLog("Cannot get proxied webdir from the server. Maybe the schedd does not have one in the REST configuration?")
return 1

return 0

def clearAutomaticBlacklist():
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def execute_schedd(self, schedd_name, collector):
self.logger.debug("Schedd found at %s", schedd_ad['MyAddress'])
schedd = htcondor.Schedd(schedd_ad)
self.logger.debug("Querying schedd for CRAB3 tasks.")
task_ads = list(schedd.xquery('TaskType =?= "ROOT" && CRAB_HC =!= "True"', QUERY_ATTRS))
task_ads = schedd.query('TaskType =?= "ROOT" && CRAB_HC =!= "True"', QUERY_ATTRS)
self.logger.info("There were %d tasks found.", len(task_ads))
ads = {}
now = time.time()
Expand Down
4 changes: 2 additions & 2 deletions src/script/Monitor/GenerateMONIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ def execute(self):
continue
schedd = htcondor.Schedd(scheddAdd)
try:
idleDags = list(schedd.xquery(pickSchedulerIdle))
idleDags = schedd.query(pickSchedulerIdle)
except Exception:
idleDags = []
try:
runningTPs = list(schedd.xquery(pickLocalRunning))
runningTPs = schedd.query(pickLocalRunning)
except Exception:
runningTPs = []
numDagIdle = len(idleDags)
Expand Down

0 comments on commit 43208f8

Please sign in to comment.