Skip to content

Commit

Permalink
Merge pull request #7476 from atsareg/fix-delete-job
Browse files Browse the repository at this point in the history
[8.0] Optimization of job deletion
  • Loading branch information
fstagni authored Feb 20, 2024
2 parents f625cf2 + cab3fc6 commit ee79ce4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/DIRAC/WorkloadManagementSystem/Agent/JobCleaningAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,18 @@ def _getJobsList(self, condDict, delay=None):
:param dict condDict: a dict like {'JobType': 'User', 'Status': 'Killed'}
:param int delay: days of delay
:returns: S_OK with jobsList
:returns: S_OK with a list of job IDs
"""
jobIDsS = set()

delayStr = f"and older than {delay}" if delay else ""
self.log.info(f"Get jobs with {str(condDict)} {delayStr}")
for order in ["JobID:ASC", "JobID:DESC"]:
result = self.jobDB.selectJobs(condDict, older=delay, orderAttribute=order, limit=self.maxJobsAtOnce)
if not result["OK"]:
return result
jobIDsS = jobIDsS.union({int(jID) for jID in result["Value"]})

return S_OK(list(jobIDsS))
# Select a random set of jobs
result = self.jobDB.selectJobs(condDict, older=delay, orderAttribute="RAND()", limit=self.maxJobsAtOnce)
if not result["OK"]:
return result

return S_OK(result["Value"])

def _getOwnerJobsDict(self, jobList):
"""
Expand Down

0 comments on commit ee79ce4

Please sign in to comment.