Skip to content

Commit

Permalink
fix: use a random selection of jobs in the job cleaning procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
atsareg committed Feb 19, 2024
1 parent f625cf2 commit cab3fc6
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 cab3fc6

Please sign in to comment.