Skip to content
Draft
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
12 changes: 3 additions & 9 deletions src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,13 @@ def deletePilots(self, pilotIDs, conn=False):
if not isinstance(pilotIDs, list):
return S_ERROR("Input argument is not a List")

failed = []

result = self._escapeValues(pilotIDs)
if not result["OK"]:
return S_ERROR(f"Failed to remove pilot: {result['Value']}")
stringIDs = ",".join(result["Value"])
for table in ["PilotOutput", "JobToPilotMapping", "PilotAgents"]:
result = self._update(f"DELETE FROM {table} WHERE PilotID in ({stringIDs})", conn=conn)
if not result["OK"]:
failed.append(table)

if failed:
return S_ERROR(f"Failed to remove pilot from {', '.join(failed)} tables")
result = self._update(f"DELETE FROM PilotAgents WHERE PilotID in ({stringIDs})", conn=conn)
if not result["OK"]:
return S_ERROR("Failed to remove pilots: ", result["Message"])
return S_OK(pilotIDs)

##########################################################################################
Expand Down
7 changes: 4 additions & 3 deletions src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ CREATE TABLE `JobToPilotMapping` (
`PilotID` INT(11) UNSIGNED NOT NULL,
`JobID` INT(11) UNSIGNED NOT NULL,
`StartTime` DATETIME NOT NULL,
KEY `JobID` (`JobID`),
KEY `PilotID` (`PilotID`)
PRIMARY KEY (`PilotID`, `JobID`),
FOREIGN KEY (`PilotID`) REFERENCES `PilotAgents`(`PilotID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

DROP TABLE IF EXISTS `PilotOutput`;
CREATE TABLE `PilotOutput` (
`PilotID` INT(11) UNSIGNED NOT NULL,
`StdOutput` MEDIUMTEXT,
`StdError` MEDIUMTEXT,
PRIMARY KEY (`PilotID`)
PRIMARY KEY (`PilotID`),
FOREIGN KEY (`PilotID`) REFERENCES `PilotAgents`(`PilotID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Loading