From 4538e952520c7bbaae5e40e396c69c4c487cf8d9 Mon Sep 17 00:00:00 2001 From: Simon Fayer Date: Thu, 5 Dec 2024 16:57:24 +0000 Subject: [PATCH] fix: Run CE cleanup step at correct point --- src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py b/src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py index 9217b190970..0072b43f255 100644 --- a/src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py +++ b/src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py @@ -750,6 +750,11 @@ def _monitorPilotsPerQueue(self, queue: str): ceType = self.queueDict[queue]["CEType"] siteName = self.queueDict[queue]["Site"] + # Call cleanup before checking pilot statuses (so cleanup always runs) + # This is needed to delete things like old cloud instances after the pilots are done + if callable(getattr(ce, "cleanupPilots", None)): + ce.cleanupPilots() + # Select pilots in a transient states result = self.pilotAgentsDB.selectPilots( { @@ -799,10 +804,6 @@ def _monitorPilotsPerQueue(self, queue: str): # Update the status of the pilots in the DB self._updatePilotsInDB(updatedPilots) - # FIXME: seems like it is only used by the CloudCE? Couldn't it be called from CloudCE.getJobStatus()? - if callable(getattr(ce, "cleanupPilots", None)): - ce.cleanupPilots() - # Check if the accounting is to be sent if self.sendAccounting: result = self.pilotAgentsDB.selectPilots(