|
36 | 36 | from DIRAC.WorkloadManagementSystem.Client.MatcherClient import MatcherClient
|
37 | 37 | from DIRAC.WorkloadManagementSystem.Client.PilotManagerClient import PilotManagerClient
|
38 | 38 | from DIRAC.WorkloadManagementSystem.Client.JobManagerClient import JobManagerClient
|
| 39 | +from DIRAC.WorkloadManagementSystem.Client.JobStateUpdateClient import JobStateUpdateClient |
39 | 40 | from DIRAC.WorkloadManagementSystem.Client.JobReport import JobReport
|
40 | 41 | from DIRAC.WorkloadManagementSystem.Client import JobStatus
|
41 | 42 | from DIRAC.WorkloadManagementSystem.Utilities.Utils import createJobWrapper
|
@@ -315,7 +316,7 @@ def execute(self):
|
315 | 316 | self.log.debug("After %sCE submitJob()" % (self.ceName))
|
316 | 317 | except Exception as subExcept: # pylint: disable=broad-except
|
317 | 318 | self.log.exception("Exception in submission", "", lException=subExcept, lExcInfo=True)
|
318 |
| - result = self._rescheduleFailedJob(jobID, "Job processing failed with exception") |
| 319 | + result = self._rescheduleFailedJob(jobID, "Job processing failed with exception", direct=True) |
319 | 320 | return self._finish(result["Message"], self.stopOnApplicationFailure)
|
320 | 321 |
|
321 | 322 | return S_OK("Job Agent cycle complete")
|
@@ -751,20 +752,23 @@ def _finish(self, message, stop=True):
|
751 | 752 | return S_OK(message)
|
752 | 753 |
|
753 | 754 | #############################################################################
|
754 |
| - def _rescheduleFailedJob(self, jobID, message): |
| 755 | + def _rescheduleFailedJob(self, jobID, message, direct=False): |
755 | 756 | """
|
756 | 757 | Set Job Status to "Rescheduled" and issue a reschedule command to the Job Manager
|
757 | 758 | """
|
758 | 759 |
|
759 | 760 | self.log.warn("Failure ==> rescheduling", "(during %s)" % (message))
|
760 | 761 |
|
761 |
| - jobReport = JobReport(int(jobID), "JobAgent@%s" % self.siteName) |
762 |
| - |
763 |
| - # Setting a job parameter does not help since the job will be rescheduled, |
764 |
| - # instead set the status with the cause and then another status showing the |
765 |
| - # reschedule operation. |
766 |
| - |
767 |
| - jobReport.setJobStatus(status=JobStatus.RESCHEDULED, applicationStatus=message, sendFlag=True) |
| 762 | + if direct: |
| 763 | + JobStateUpdateClient().setJobStatus( |
| 764 | + int(jobID), status=JobStatus.RESCHEDULED, applicationStatus=message, source="JobAgent@%s", force=True |
| 765 | + ) |
| 766 | + else: |
| 767 | + jobReport = JobReport(int(jobID), "JobAgent@%s" % self.siteName) |
| 768 | + # Setting a job parameter does not help since the job will be rescheduled, |
| 769 | + # instead set the status with the cause and then another status showing the |
| 770 | + # reschedule operation. |
| 771 | + jobReport.setJobStatus(status=JobStatus.RESCHEDULED, applicationStatus=message, sendFlag=True) |
768 | 772 |
|
769 | 773 | self.log.info("Job will be rescheduled")
|
770 | 774 | result = JobManagerClient().rescheduleJob(jobID)
|
|
0 commit comments