From a5bedbf2d767eac2b4c5d30cc096874ff0ab66aa Mon Sep 17 00:00:00 2001 From: aldbr Date: Wed, 17 Jan 2024 08:18:55 +0100 Subject: [PATCH] fix: reschedule the correct job in JobAgent --- src/DIRAC/WorkloadManagementSystem/Agent/JobAgent.py | 5 ++++- .../Agent/test/Test_Agent_JobAgent.py | 6 +----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/DIRAC/WorkloadManagementSystem/Agent/JobAgent.py b/src/DIRAC/WorkloadManagementSystem/Agent/JobAgent.py index d88fe0ef78a..2757921c184 100755 --- a/src/DIRAC/WorkloadManagementSystem/Agent/JobAgent.py +++ b/src/DIRAC/WorkloadManagementSystem/Agent/JobAgent.py @@ -694,7 +694,8 @@ def _checkSubmittedJobs(self): submissionErrors = [] payloadErrors = [] originalJobID = self.jobReport.jobID - for jobID, taskID in self.submissionDict.items(): + for jobID in list(self.submissionDict.keys()): + taskID = self.submissionDict[jobID] if taskID not in self.computingElement.taskResults: continue @@ -731,7 +732,9 @@ def _checkSubmittedJobs(self): self.log.info(message) # Remove taskID from computingElement.taskResults as it has been treated + # Remove jobID from submissionDict as it has been treated del self.computingElement.taskResults[taskID] + del self.submissionDict[jobID] self.jobReport.setJob(originalJobID) return S_OK((submissionErrors, payloadErrors)) diff --git a/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_JobAgent.py b/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_JobAgent.py index 0495fb495de..2a53908c3a4 100644 --- a/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_JobAgent.py +++ b/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_JobAgent.py @@ -517,6 +517,7 @@ def test_submitAndCheckJob(mocker, localCE, job, expectedResult1, expectedResult jobAgent.log = gLogger.getSubLogger("JobAgent") jobAgent._initializeComputingElement(localCE) jobAgent.jobReport = JobReport(jobID) + jobAgent.jobSubmissionDelay = 3 # Submit a job result = jobAgent._submitJob( @@ -547,10 +548,6 @@ def test_submitAndCheckJob(mocker, localCE, job, expectedResult1, expectedResult assert result["OK"] assert result["Value"] == expectedResult1 - # Check that the job is still present in jobAgent.submissionDict - assert len(jobAgent.submissionDict) == 1 - assert jobID in jobAgent.submissionDict - # If the submission is synchronous jobAgent.computingElement.taskResults # should not contain the result anymore: already processed by checkSubmittedJobs if not jobAgent.computingElement.ceParameters.get("AsyncSubmission", False): @@ -576,7 +573,6 @@ def test_submitAndCheckJob(mocker, localCE, job, expectedResult1, expectedResult assert result["Value"] == expectedResult2 # From here, taskResults should be empty - assert jobID in jobAgent.submissionDict assert len(jobAgent.computingElement.taskResults) == 0