Skip to content

Commit 21634fb

Browse files
authored
Merge pull request #7204 from DIRACGridBot/cherry-pick-2-b37a83835-integration
[sweep:integration] feat (TransformationCleaningAgent): chunk the file removals
2 parents e7afdc6 + 0332da8 commit 21634fb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/DIRAC/TransformationSystem/Agent/TransformationCleaningAgent.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,20 +386,24 @@ def cleanContent(self, directory):
386386

387387
# Executing with shifter proxy
388388
gConfigurationData.setOptionInCFG("/DIRAC/Security/UseServerCertificate", "false")
389-
res = DataManager().removeFile(filesFound, force=True)
389+
failed = {}
390+
for chunkId, filesChunk in enumerate(breakListIntoChunks(filesFound, 500)):
391+
self.log.info("Removing chunk", chunkId)
392+
res = DataManager().removeFile(filesChunk, force=True)
393+
if not res["OK"]:
394+
failed.update(dict.fromkeys(filesChunk, res["Message"]))
395+
failed.update(res["Value"]["Failed"])
390396
gConfigurationData.setOptionInCFG("/DIRAC/Security/UseServerCertificate", "true")
391397

392-
if not res["OK"]:
393-
return res
394398
realFailure = False
395-
for lfn, reason in res["Value"]["Failed"].items():
399+
for lfn, reason in failed.items():
396400
if "File does not exist" in str(reason):
397401
self.log.warn(f"File {lfn} not found in some catalog: ")
398402
else:
399403
self.log.error("Failed to remove file found in the catalog", f"{lfn} {reason}")
400404
realFailure = True
401405
if realFailure:
402-
return S_ERROR("Failed to remove all files found in the catalog")
406+
return S_ERROR("Failed to remove some files found in the catalog")
403407
return S_OK()
404408

405409
def __getCatalogDirectoryContents(self, directories):

0 commit comments

Comments
 (0)