Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/DIRAC/Interfaces/API/DiracAdmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from DIRAC.WorkloadManagementSystem.Client.JobManagerClient import JobManagerClient
from DIRAC.WorkloadManagementSystem.Client.PilotManagerClient import PilotManagerClient
from DIRAC.WorkloadManagementSystem.Client.WMSAdministratorClient import WMSAdministratorClient
from DIRAC.WorkloadManagementSystem.Service.WMSUtilities import (
killPilotsInQueues,
)

voName = ""
ret = getProxyInfo(disableVOMS=True)
Expand Down Expand Up @@ -452,8 +455,28 @@ def killPilot(self, gridReference):
if not isinstance(gridReference, (str, list)):
return self._errorReport("Expected string or list of strings for pilot reference")

result = PilotManagerClient().killPilot(gridReference)
return result
# Make a list if it is not yet
if isinstance(gridReference, str):
gridReference = [gridReference]

# Regroup pilots per site
pilotRefDict = {}
for pilotReference in gridReference:
result = PilotManagerClient().getPilotInfo(pilotReference)
if not result["OK"] or not result["Value"]:
return S_ERROR(f"Failed to get info for pilot {pilotReference}")

pilotDict = result["Value"][pilotReference]
queue = "@@@".join(
[pilotDict["VO"], pilotDict["GridSite"], pilotDict["DestinationSite"], pilotDict["Queue"]]
)
gridType = pilotDict["GridType"]
pilotRefDict.setdefault(queue, {})
pilotRefDict[queue].setdefault("PilotList", [])
pilotRefDict[queue]["PilotList"].append(pilotReference)
pilotRefDict[queue]["GridType"] = gridType

return killPilotsInQueues(pilotRefDict)

#############################################################################
def getPilotLoggingInfo(self, gridReference):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from DIRAC.WorkloadManagementSystem.Service.WMSUtilities import (
getPilotCE,
getPilotRef,
killPilotsInQueues,
setPilotCredentials,
)

Expand Down Expand Up @@ -301,35 +300,6 @@ def export_getPilots(cls, jobID):

return cls.pilotAgentsDB.getPilotInfo(pilotID=result["Value"])

##############################################################################
types_killPilot = [[str, list]]

@classmethod
def export_killPilot(cls, pilotRefList):
"""Kill the specified pilots"""
# Make a list if it is not yet
if isinstance(pilotRefList, str):
pilotRefList = [pilotRefList]

# Regroup pilots per site
pilotRefDict = {}
for pilotReference in pilotRefList:
result = cls.pilotAgentsDB.getPilotInfo(pilotReference)
if not result["OK"] or not result["Value"]:
return S_ERROR(f"Failed to get info for pilot {pilotReference}")

pilotDict = result["Value"][pilotReference]
queue = "@@@".join(
[pilotDict["VO"], pilotDict["GridSite"], pilotDict["DestinationSite"], pilotDict["Queue"]]
)
gridType = pilotDict["GridType"]
pilotRefDict.setdefault(queue, {})
pilotRefDict[queue].setdefault("PilotList", [])
pilotRefDict[queue]["PilotList"].append(pilotReference)
pilotRefDict[queue]["GridType"] = gridType

return killPilotsInQueues(pilotRefDict)

##############################################################################
types_setJobForPilot = [[str, int], str]

Expand Down
Loading