From 43208f8307874dab3d255415b62aa45c0cd1e32f Mon Sep 17 00:00:00 2001 From: Stefano Belforte Date: Mon, 12 Aug 2024 22:03:20 +0200 Subject: [PATCH] Change xquery to query 8613 (#8615) * use schedd.query() instead of schedd.xquery(). Fix #8613 * cleanup reporting of webdir in AdjustSites --- scripts/AdjustSites.py | 21 +++---------------- .../Actions/Recurring/RenewRemoteProxies.py | 2 +- src/script/Monitor/GenerateMONIT.py | 4 ++-- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/scripts/AdjustSites.py b/scripts/AdjustSites.py index 60527448d8..409034b1a1 100644 --- a/scripts/AdjustSites.py +++ b/scripts/AdjustSites.py @@ -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(): """ diff --git a/src/python/TaskWorker/Actions/Recurring/RenewRemoteProxies.py b/src/python/TaskWorker/Actions/Recurring/RenewRemoteProxies.py index 76ce851c64..3cac835b20 100644 --- a/src/python/TaskWorker/Actions/Recurring/RenewRemoteProxies.py +++ b/src/python/TaskWorker/Actions/Recurring/RenewRemoteProxies.py @@ -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() diff --git a/src/script/Monitor/GenerateMONIT.py b/src/script/Monitor/GenerateMONIT.py index 8bee8e0ec1..9e148e38fa 100644 --- a/src/script/Monitor/GenerateMONIT.py +++ b/src/script/Monitor/GenerateMONIT.py @@ -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)