From c38190e44e3c06b90d7cc06e2b4890f2811c42b9 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Tue, 13 Aug 2024 17:40:30 +0200 Subject: [PATCH] sweep: #7748 RSS fix: delete the occupancy cache only for older entries --- .../Command/FreeDiskSpaceCommand.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py b/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py index 87f1f878fb2..0276098b9b4 100644 --- a/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py +++ b/src/DIRAC/ResourceStatusSystem/Command/FreeDiskSpaceCommand.py @@ -7,20 +7,19 @@ For the moment, when you see "token" or "space token" here, just read "StorageElement". """ -import sys import errno +import sys +from datetime import datetime, timedelta, timezone -from datetime import datetime - -from DIRAC import S_OK, S_ERROR -from DIRAC.Core.Utilities.File import convertSizeUnits +from DIRAC import S_ERROR, S_OK from DIRAC.AccountingSystem.Client.DataStoreClient import gDataStoreClient from DIRAC.AccountingSystem.Client.Types.StorageOccupancy import StorageOccupancy +from DIRAC.Core.Utilities.File import convertSizeUnits from DIRAC.DataManagementSystem.Utilities.DMSHelpers import DMSHelpers -from DIRAC.ResourceStatusSystem.Command.Command import Command -from DIRAC.ResourceStatusSystem.Utilities import CSHelpers from DIRAC.Resources.Storage.StorageElement import StorageElement from DIRAC.ResourceStatusSystem.Client.ResourceManagementClient import ResourceManagementClient +from DIRAC.ResourceStatusSystem.Command.Command import Command +from DIRAC.ResourceStatusSystem.Utilities import CSHelpers class FreeDiskSpaceCommand(Command): @@ -204,7 +203,9 @@ def _cleanCommand(self, toDelete=None): if not toDelete: toDelete = [] - res = self.rmClient.selectSpaceTokenOccupancyCache() + res = self.rmClient.selectSpaceTokenOccupancyCache( + meta={"older": ["LastCheckTime", datetime.now(timezone.utc) - timedelta(hours=6)]} + ) if not res["OK"]: return res storedSEsSet = {(sse[0], sse[1]) for sse in res["Value"]}