Skip to content

Commit

Permalink
Replace xquery with query, due to deprecation of the former since HTC…
Browse files Browse the repository at this point in the history
…ondor 10.7.0
  • Loading branch information
khurtado committed Oct 24, 2024
1 parent 3917282 commit 586684e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bin/adhoc-scripts/drainAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def getCondorJobs():
"""
jobDict = {}
schedd = condor.Schedd()
jobs = schedd.xquery('WMAgent_AgentName == "WMAgent"', ['WMAgent_RequestName', 'JobStatus'])
jobs = schedd.query('WMAgent_AgentName == "WMAgent"', ['WMAgent_RequestName', 'JobStatus'])
for job in jobs:
jobStatus = job['JobStatus']
jobDict.setdefault(jobStatus, {})
Expand Down
10 changes: 5 additions & 5 deletions src/python/WMCore/BossAir/Plugins/SimpleCondorPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ def track(self, jobs):

schedd = htcondor.Schedd()

logging.debug("Start: Retrieving classAds using Condor Python XQuery")
logging.debug("Start: Retrieving classAds using Condor Python query")
try:
itobj = schedd.xquery("WMAgent_AgentName == %s" % classad.quote(self.agent),
jobAds = schedd.query("WMAgent_AgentName == %s" % classad.quote(self.agent),
['ClusterId', 'ProcId', 'JobStatus', 'MachineAttrGLIDEIN_CMSSite0'])
for jobAd in itobj:
for jobAd in jobAds:
gridId = "%s.%s" % (jobAd['ClusterId'], jobAd['ProcId'])
jobStatus = SimpleCondorPlugin.exitCodeMap().get(jobAd.get('JobStatus'), 'Unknown')
location = jobAd.get('MachineAttrGLIDEIN_CMSSite0', None)
Expand Down Expand Up @@ -372,10 +372,10 @@ def updateSiteInformation(self, jobs, siteName, excludeSite):
origSiteLists = set()

try:
itobj = sd.xquery('WMAgent_AgentName =?= %s && JobStatus =?= 1' % classad.quote(self.agent),
jobAds = sd.query('WMAgent_AgentName =?= %s && JobStatus =?= 1' % classad.quote(self.agent),
['WMAgent_JobID', 'DESIRED_Sites', 'ExtDESIRED_Sites'])

for jobAd in itobj:
for jobAd in jobAds:
jobAdId = jobAd.get('WMAgent_JobID')
desiredSites = jobAd.get('DESIRED_Sites')
extDesiredSites = jobAd.get('ExtDESIRED_Sites')
Expand Down
5 changes: 2 additions & 3 deletions src/python/WMCore/Services/PyCondor/PyCondorAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def getCondorJobsSummary(self):
Retrieves a job summary from the HTCondor Schedd object
:return: a list of classads representing the matching jobs, or None if failed
"""
### NOTE: SummaryOnly does not work with xquery method
jobs = None # return None to signalize the query failed
queryOpts = htcondor.htcondor.QueryOpts.SummaryOnly
try:
Expand Down Expand Up @@ -68,12 +67,12 @@ def getCondorJobs(self, constraint='true', attrList=None, limit=-1, opts="Defaul
msg = "Querying condor schedd with params: constraint=%s, attrList=%s, limit=%s, opts=%s"
logging.info(msg, constraint, attrList, limit, opts)
try:
return self.schedd.xquery(constraint, attrList, limit, opts=opts)
return self.schedd.query(constraint, attrList, limit, opts=opts)
except Exception:
self.recreateSchedd()

# if we hit another exception, let it be raised up in the chain
return self.schedd.xquery(constraint, attrList, limit, opts=opts)
return self.schedd.query(constraint, attrList, limit, opts=opts)

def editCondorJobs(self, job_spec, attr, value):
"""
Expand Down

0 comments on commit 586684e

Please sign in to comment.