2222from DIRAC .Core .Utilities .ObjectLoader import ObjectLoader
2323from DIRAC .FrameworkSystem .Client .ProxyManagerClient import gProxyManager
2424from DIRAC .StorageManagementSystem .Client .StorageManagerClient import StorageManagerClient
25- from DIRAC .WorkloadManagementSystem .Client .JobStatus import filterJobStateTransition
2625from DIRAC .WorkloadManagementSystem .Client import JobStatus
26+ from DIRAC .WorkloadManagementSystem .Client .JobStatus import filterJobStateTransition
2727from DIRAC .WorkloadManagementSystem .Service .JobPolicy import (
2828 RIGHT_DELETE ,
2929 RIGHT_KILL ,
@@ -435,13 +435,14 @@ def export_removeJob(self, jobIDs):
435435
436436 return S_OK (validJobList )
437437
438- def __deleteJob (self , jobID ):
439- """Set the job status to "Deleted" and remove the pilot that ran.
438+ def __deleteJob (self , jobID , force = False ):
439+ """Set the job status to "Deleted"
440+ and remove the pilot that ran and its logging info if the pilot is finished.
440441
441442 :param int jobID: job ID
442443 :return: S_OK()/S_ERROR()
443444 """
444- if not (result := self .jobDB .setJobStatus (jobID , JobStatus .DELETED , "Checking accounting" ))["OK" ]:
445+ if not (result := self .jobDB .setJobStatus (jobID , JobStatus .DELETED , "Checking accounting" , force = force ))["OK" ]:
445446 return result
446447
447448 if not (result := self .taskQueueDB .deleteJob (jobID ))["OK" ]:
@@ -469,7 +470,7 @@ def __deleteJob(self, jobID):
469470
470471 return S_OK ()
471472
472- def __killJob (self , jobID , sendKillCommand = True ):
473+ def __killJob (self , jobID , sendKillCommand = True , force = False ):
473474 """Kill one job
474475
475476 :param int jobID: job ID
@@ -482,14 +483,16 @@ def __killJob(self, jobID, sendKillCommand=True):
482483 return result
483484
484485 self .log .info ("Job marked for termination" , jobID )
485- if not (result := self .jobDB .setJobStatus (jobID , JobStatus .KILLED , "Marked for termination" ))["OK" ]:
486+ if not (result := self .jobDB .setJobStatus (jobID , JobStatus .KILLED , "Marked for termination" , force = force ))[
487+ "OK"
488+ ]:
486489 self .log .warn ("Failed to set job Killed status" , result ["Message" ])
487490 if not (result := self .taskQueueDB .deleteJob (jobID ))["OK" ]:
488491 self .log .warn ("Failed to delete job from the TaskQueue" , result ["Message" ])
489492
490493 return S_OK ()
491494
492- def _kill_delete_jobs (self , jobIDList , right ):
495+ def _kill_delete_jobs (self , jobIDList , right , force = False ):
493496 """Kill (== set the status to "KILLED") or delete (== set the status to "DELETED") jobs as necessary
494497
495498 :param list jobIDList: job IDs
@@ -529,12 +532,12 @@ def _kill_delete_jobs(self, jobIDList, right):
529532 stagingJobList = [jobID for jobID , sDict in result ["Value" ].items () if sDict ["Status" ] == JobStatus .STAGING ]
530533
531534 for jobID in killJobList :
532- result = self .__killJob (jobID )
535+ result = self .__killJob (jobID , force = force )
533536 if not result ["OK" ]:
534537 badIDs .append (jobID )
535538
536539 for jobID in deleteJobList :
537- result = self .__deleteJob (jobID )
540+ result = self .__deleteJob (jobID , force = force )
538541 if not result ["OK" ]:
539542 badIDs .append (jobID )
540543
@@ -567,28 +570,28 @@ def _kill_delete_jobs(self, jobIDList, right):
567570 ###########################################################################
568571 types_deleteJob = []
569572
570- def export_deleteJob (self , jobIDs ):
573+ def export_deleteJob (self , jobIDs , force = False ):
571574 """Delete jobs specified in the jobIDs list
572575
573576 :param list jobIDs: list of job IDs
574577
575578 :return: S_OK/S_ERROR
576579 """
577580
578- return self ._kill_delete_jobs (jobIDs , RIGHT_DELETE )
581+ return self ._kill_delete_jobs (jobIDs , RIGHT_DELETE , force = force )
579582
580583 ###########################################################################
581584 types_killJob = []
582585
583- def export_killJob (self , jobIDs ):
586+ def export_killJob (self , jobIDs , force = False ):
584587 """Kill jobs specified in the jobIDs list
585588
586589 :param list jobIDs: list of job IDs
587590
588591 :return: S_OK/S_ERROR
589592 """
590593
591- return self ._kill_delete_jobs (jobIDs , RIGHT_KILL )
594+ return self ._kill_delete_jobs (jobIDs , RIGHT_KILL , force = force )
592595
593596 ###########################################################################
594597 types_resetJob = []
0 commit comments