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
8+ from DIRAC .WorkloadManagementSystem .Service .JobPolicy import RIGHT_KILL , RIGHT_DELETE
99
1010
1111def _deleteJob (jobID , force = False ):
@@ -85,19 +85,13 @@ def kill_delete_jobs(right, validJobList, nonauthJobList=[], force=False):
8585 return filterRes
8686 killJobList .extend (filterRes ["Value" ])
8787
88- if not right == RIGHT_KILL :
88+ if right == RIGHT_DELETE :
8989 # Get the jobs allowed to transition to the Deleted state
9090 filterRes = filterJobStateTransition (validJobList , JobStatus .DELETED )
9191 if not filterRes ["OK" ]:
9292 return filterRes
9393 deleteJobList .extend (filterRes ["Value" ])
9494
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-
10195 for jobID in killJobList :
10296 result = _killJob (jobID , force = force )
10397 if not result ["OK" ]:
@@ -108,6 +102,12 @@ def kill_delete_jobs(right, validJobList, nonauthJobList=[], force=False):
108102 if not result ["OK" ]:
109103 badIDs .append (jobID )
110104
105+ # Look for jobs that are in the Staging state to send kill signal to the stager
106+ result = JobDB ().getJobsAttributes (killJobList , ["Status" ])
107+ if not result ["OK" ]:
108+ return result
109+ stagingJobList = [jobID for jobID , sDict in result ["Value" ].items () if sDict ["Status" ] == JobStatus .STAGING ]
110+
111111 if stagingJobList :
112112 stagerDB = StorageManagementDB ()
113113 gLogger .info ("Going to send killing signal to stager as well!" )
0 commit comments