Skip to content

Commit c1c49c4

Browse files
committed
fix: reschedule the correct job in JobAgent
1 parent 5d8c98c commit c1c49c4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/JobAgent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,10 @@ def _checkSubmittedJobs(self):
694694
submissionErrors = []
695695
payloadErrors = []
696696
originalJobID = self.jobReport.jobID
697-
for jobID, taskID in self.submissionDict.items():
697+
# Loop over the jobIDs submitted to the CE
698+
# Here we iterate over a copy of the keys because we are modifying the dictionary within the loop
699+
for jobID in list(self.submissionDict.keys()):
700+
taskID = self.submissionDict[jobID]
698701
if taskID not in self.computingElement.taskResults:
699702
continue
700703

@@ -731,7 +734,9 @@ def _checkSubmittedJobs(self):
731734
self.log.info(message)
732735

733736
# Remove taskID from computingElement.taskResults as it has been treated
737+
# Remove jobID from submissionDict as it has been treated
734738
del self.computingElement.taskResults[taskID]
739+
del self.submissionDict[jobID]
735740

736741
self.jobReport.setJob(originalJobID)
737742
return S_OK((submissionErrors, payloadErrors))

src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_JobAgent.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ def test_submitAndCheckJob(mocker, localCE, job, expectedResult1, expectedResult
517517
jobAgent.log = gLogger.getSubLogger("JobAgent")
518518
jobAgent._initializeComputingElement(localCE)
519519
jobAgent.jobReport = JobReport(jobID)
520+
jobAgent.jobSubmissionDelay = 3
520521

521522
# Submit a job
522523
result = jobAgent._submitJob(
@@ -547,10 +548,6 @@ def test_submitAndCheckJob(mocker, localCE, job, expectedResult1, expectedResult
547548
assert result["OK"]
548549
assert result["Value"] == expectedResult1
549550

550-
# Check that the job is still present in jobAgent.submissionDict
551-
assert len(jobAgent.submissionDict) == 1
552-
assert jobID in jobAgent.submissionDict
553-
554551
# If the submission is synchronous jobAgent.computingElement.taskResults
555552
# should not contain the result anymore: already processed by checkSubmittedJobs
556553
if not jobAgent.computingElement.ceParameters.get("AsyncSubmission", False):
@@ -576,7 +573,6 @@ def test_submitAndCheckJob(mocker, localCE, job, expectedResult1, expectedResult
576573
assert result["Value"] == expectedResult2
577574

578575
# From here, taskResults should be empty
579-
assert jobID in jobAgent.submissionDict
580576
assert len(jobAgent.computingElement.taskResults) == 0
581577

582578

0 commit comments

Comments
 (0)