From 019b648bb1068a3532a311c5fe61b1a4fe4bdfa2 Mon Sep 17 00:00:00 2001 From: Christophe Haen Date: Tue, 27 Aug 2024 17:41:26 +0200 Subject: [PATCH] sweep: #7761 fix (RSS): do not use timezone datetime --- .../DataManagementSystem/Client/FTS3Job.py | 1 + .../Command/FreeDiskSpaceCommand.py | 4 ++-- src/DIRAC/Resources/Storage/StorageElement.py | 20 ++++++++++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/DIRAC/DataManagementSystem/Client/FTS3Job.py b/src/DIRAC/DataManagementSystem/Client/FTS3Job.py index 9e597c1bb57..708edfd9d30 100644 --- a/src/DIRAC/DataManagementSystem/Client/FTS3Job.py +++ b/src/DIRAC/DataManagementSystem/Client/FTS3Job.py @@ -205,6 +205,7 @@ def monitor(self, context=None, ftsServer=None, ucert=None): # monitoring calls if file_state in FTS3File.FTS_FINAL_STATES: filesStatus[file_id]["ftsGUID"] = None + # TODO: update status to defunct if not recoverable here ? # If the file is not in a final state, but the job is, we return an error # FTS can have inconsistencies where the FTS Job is in a final state diff --git a/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py b/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py index 0276098b9b4..55b3a80b944 100644 --- a/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py +++ b/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py @@ -9,7 +9,7 @@ """ import errno import sys -from datetime import datetime, timedelta, timezone +from datetime import datetime, timedelta from DIRAC import S_ERROR, S_OK from DIRAC.AccountingSystem.Client.DataStoreClient import gDataStoreClient @@ -204,7 +204,7 @@ def _cleanCommand(self, toDelete=None): toDelete = [] res = self.rmClient.selectSpaceTokenOccupancyCache( - meta={"older": ["LastCheckTime", datetime.now(timezone.utc) - timedelta(hours=6)]} + meta={"older": ["LastCheckTime", datetime.utcnow() - timedelta(hours=6)]} ) if not res["OK"]: return res diff --git a/src/DIRAC/Resources/Storage/StorageElement.py b/src/DIRAC/Resources/Storage/StorageElement.py index 688ccfb7cf9..b11e6382f2c 100755 --- a/src/DIRAC/Resources/Storage/StorageElement.py +++ b/src/DIRAC/Resources/Storage/StorageElement.py @@ -1,5 +1,6 @@ """ This is the StorageElement module. It implements The StorageElementItem as well as the caching system """ + # # custom duty @@ -257,11 +258,13 @@ def __init__(self, name, protocolSections=None, vo=None, hideExceptions=False): self.localStageProtocolList = ( stageProto if stageProto - else accessProto - if accessProto - else globalStageProto - if globalStageProto - else self.localAccessProtocolList + else ( + accessProto + if accessProto + else globalStageProto + if globalStageProto + else self.localAccessProtocolList + ) ) self.log.debug(f"localStageProtocolList {self.localStageProtocolList}") @@ -421,6 +424,13 @@ def getOccupancy(self, unit="MB", **kwargs): """ log = self.log.getSubLogger("getOccupancy") + res = self.isValid(operation="getOccupancy") + if not res["OK"]: + return res + else: + if not self.valid: + return S_ERROR(self.errorReason) + if "occupancyLFN" not in kwargs: occupancyLFN = self.options.get("OccupancyLFN") if not occupancyLFN: