55from DIRAC .WorkloadManagementSystem .DB .JobDB import JobDB
66from DIRAC .WorkloadManagementSystem .DB .PilotAgentsDB import PilotAgentsDB
77from DIRAC .WorkloadManagementSystem .DB .TaskQueueDB import TaskQueueDB
8- from DIRAC .WorkloadManagementSystem .Service .JobPolicy import RIGHT_KILL
9-
8+ from DIRAC .WorkloadManagementSystem .Service .JobPolicy import RIGHT_KILL , RIGHT_DELETE
109
1110def _deleteJob (jobID , force = False ):
1211 """Set the job status to "Deleted"
@@ -85,19 +84,13 @@ def kill_delete_jobs(right, validJobList, nonauthJobList=[], force=False):
8584 return filterRes
8685 killJobList .extend (filterRes ["Value" ])
8786
88- if not right == RIGHT_KILL :
87+ if right == RIGHT_DELETE :
8988 # Get the jobs allowed to transition to the Deleted state
9089 filterRes = filterJobStateTransition (validJobList , JobStatus .DELETED )
9190 if not filterRes ["OK" ]:
9291 return filterRes
9392 deleteJobList .extend (filterRes ["Value" ])
9493
95- # Look for jobs that are in the Staging state to send kill signal to the stager
96- result = JobDB ().getJobsAttributes (killJobList , ["Status" ])
97- if not result ["OK" ]:
98- return result
99- stagingJobList = [jobID for jobID , sDict in result ["Value" ].items () if sDict ["Status" ] == JobStatus .STAGING ]
100-
10194 for jobID in killJobList :
10295 result = _killJob (jobID , force = force )
10396 if not result ["OK" ]:
@@ -108,6 +101,12 @@ def kill_delete_jobs(right, validJobList, nonauthJobList=[], force=False):
108101 if not result ["OK" ]:
109102 badIDs .append (jobID )
110103
104+ # Look for jobs that are in the Staging state to send kill signal to the stager
105+ result = JobDB ().getJobsAttributes (killJobList , ["Status" ])
106+ if not result ["OK" ]:
107+ return result
108+ stagingJobList = [jobID for jobID , sDict in result ["Value" ].items () if sDict ["Status" ] == JobStatus .STAGING ]
109+
111110 if stagingJobList :
112111 stagerDB = StorageManagementDB ()
113112 gLogger .info ("Going to send killing signal to stager as well!" )
0 commit comments