Skip to content

Commit 970cb7a

Browse files
authored
Merge pull request #7434 from fstagni/80_avoid_double_counting
[8.0] StatesAccountingAgent: skip the first iteration in order to avoid double commit after a restart
2 parents 99f68cc + a693aec commit 970cb7a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/StatesAccountingAgent.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
"""
1010
import datetime
1111

12-
from DIRAC import S_OK, S_ERROR
12+
from DIRAC import S_ERROR, S_OK
13+
from DIRAC.AccountingSystem.Client.DataStoreClient import DataStoreClient
14+
from DIRAC.AccountingSystem.Client.Types.WMSHistory import WMSHistory
1315
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
1416
from DIRAC.Core.Base.AgentModule import AgentModule
1517
from DIRAC.Core.Utilities import TimeUtilities
16-
from DIRAC.AccountingSystem.Client.Types.WMSHistory import WMSHistory
17-
from DIRAC.AccountingSystem.Client.DataStoreClient import DataStoreClient
1818
from DIRAC.MonitoringSystem.Client.MonitoringReporter import MonitoringReporter
1919
from DIRAC.WorkloadManagementSystem.DB.JobDB import JobDB
2020
from DIRAC.WorkloadManagementSystem.DB.PilotAgentsDB import PilotAgentsDB
@@ -76,6 +76,12 @@ def initialize(self):
7676

7777
def execute(self):
7878
"""Main execution method"""
79+
80+
# on the first iteration of the agent, do nothing in order to avoid double committing after a restart
81+
if self.am_getModuleParam("cyclesDone") == 0:
82+
self.log.notice("Skipping the first iteration of the agent")
83+
return S_OK()
84+
7985
# PilotsHistory to Monitoring
8086
if "Monitoring" in self.pilotMonitoringOption:
8187
self.log.info("Committing PilotsHistory to Monitoring")

0 commit comments

Comments
 (0)