Skip to content

Commit e741794

Browse files
authored
Merge pull request #8284 from chaen/v9.0_feat_forceSuccessfulCSSync
[9.0] force successful sync of remote CS for Agent
2 parents 5b10c4f + 71c4ec3 commit e741794

File tree

3 files changed

+67
-63
lines changed

3 files changed

+67
-63
lines changed

src/DIRAC/ConfigurationSystem/Client/LocalConfiguration.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
""" This is the guy that parses and interprets the local configuration options.
2-
"""
1+
"""This is the guy that parses and interprets the local configuration options."""
2+
33
import re
44
import os
55
import sys
@@ -286,16 +286,18 @@ def __checkMandatoryOptions(self):
286286
gLogger.exception()
287287
return S_ERROR(str(e))
288288

289-
def initialize(self, *, returnErrors=False):
289+
def initialize(self, *, returnErrors=False, requireSuccessfulSync=False):
290290
"""Entrypoint used by :py:class:`DIRAC.initialize`
291291
292+
:param requireSuccessfulSync: fails if syncing with the remote did not work
293+
292294
TODO: This is currently a hack that returns a list of errors for so it
293295
can be used by ``__addUserDataToConfiguration``. This entire module
294296
should be refactored and simplified with ``Script.parseCommandLine``.
295297
"""
296298
errorsList = self.__loadCFGFiles()
297299
if gConfigurationData.getServers():
298-
retVal = self.syncRemoteConfiguration()
300+
retVal = self.syncRemoteConfiguration(strict=requireSuccessfulSync)
299301
if not retVal["OK"]:
300302
return retVal
301303
else:
@@ -321,22 +323,23 @@ def __initLogger(self, componentName, logSection, forceInit=False):
321323
gLogger.showHeaders(True)
322324
gLogger.enableLogsFromExternalLibs()
323325

324-
def loadUserData(self):
326+
def loadUserData(self, requireSuccessfulSync=False):
325327
"""
326328
This is the magic method that reads the command line and processes it
327329
It is used by the Script Base class and the dirac-service and dirac-agent scripts
328330
Before being called:
329331
- any additional switches to be processed
330332
- mandatory and default configuration configuration options must be defined.
331333
334+
:param requireSuccessfulSync: if True, will fail if the sync with remote server failed
332335
"""
333336
if self.initialized:
334337
return S_OK()
335338
self.initialized = True
336339
try:
337340
if not self.isParsed:
338341
self.__parseCommandLine() # Parse command line
339-
retVal = self.__addUserDataToConfiguration()
342+
retVal = self.__addUserDataToConfiguration(requireSuccessfulSync=requireSuccessfulSync)
340343

341344
for optionTuple in self.optionalEntryList:
342345
optionPath = self.__getAbsolutePath(optionTuple[0])
@@ -496,8 +499,8 @@ def __loadCFGFiles(self):
496499

497500
return errorsList
498501

499-
def __addUserDataToConfiguration(self):
500-
retVal = self.initialize(returnErrors=True)
502+
def __addUserDataToConfiguration(self, requireSuccessfulSync=False):
503+
retVal = self.initialize(returnErrors=True, requireSuccessfulSync=requireSuccessfulSync)
501504
if not retVal["OK"]:
502505
return retVal
503506
errorsList = retVal["Value"]

src/DIRAC/Core/scripts/dirac_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def main():
2525
localCfg.setConfigurationForAgent(agentName)
2626
localCfg.addDefaultEntry("/DIRAC/Security/UseServerCertificate", "yes")
2727
localCfg.addDefaultEntry("LogColor", True)
28-
resultDict = localCfg.loadUserData()
28+
resultDict = localCfg.loadUserData(requireSuccessfulSync=True)
2929
if not resultDict["OK"]:
3030
gLogger.error("There were errors when loading configuration", resultDict["Message"])
3131
sys.exit(1)

src/DIRAC/__init__.py

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,60 @@
11
"""
2-
DIRAC - Distributed Infrastructure with Remote Agent Control
3-
4-
The distributed data production and analysis system of LHCb and other VOs.
5-
6-
DIRAC is a software framework for distributed computing which
7-
allows to integrate various computing resources in a single
8-
system. At the same time it integrates all kinds of computing
9-
activities like Monte Carlo simulations, data processing, or
10-
final user analysis.
11-
12-
It is build as number of cooperating systems:
13-
- Accounting
14-
- Configuration
15-
- Core
16-
- Base
17-
- Security
18-
- Utilities
19-
- Workflow
20-
- Framework
21-
- RequestManagement
22-
- Resources
23-
- Transformation
24-
25-
Which are used by other system providing functionality to
26-
the end user:
27-
- DataManagement
28-
- Interfaces
29-
- ResourceStatus
30-
- StorageManagement
31-
- WorkloadManagement
32-
33-
It defines the following data members:
34-
- version: DIRAC version string
35-
36-
- errorMail: mail address for important errors
37-
- alarmMail: mail address for important alarms
38-
39-
It loads Modules from :
40-
- DIRAC.Core.Utililies
41-
42-
It loads:
43-
- S_OK: OK return structure
44-
- S_ERROR: ERROR return structure
45-
- gLogger: global Logger object
46-
- gConfig: global Config object
47-
48-
It defines the following functions:
49-
- abort: aborts execution
50-
- exit: finish execution using callbacks
51-
- siteName: returns DIRAC name for current site
52-
53-
- getPlatform(): DIRAC platform string for current host
54-
- getPlatformTuple(): DIRAC platform tuple for current host
2+
DIRAC - Distributed Infrastructure with Remote Agent Control
3+
4+
The distributed data production and analysis system of LHCb and other VOs.
5+
6+
DIRAC is a software framework for distributed computing which
7+
allows to integrate various computing resources in a single
8+
system. At the same time it integrates all kinds of computing
9+
activities like Monte Carlo simulations, data processing, or
10+
final user analysis.
11+
12+
It is build as number of cooperating systems:
13+
- Accounting
14+
- Configuration
15+
- Core
16+
- Base
17+
- Security
18+
- Utilities
19+
- Workflow
20+
- Framework
21+
- RequestManagement
22+
- Resources
23+
- Transformation
24+
25+
Which are used by other system providing functionality to
26+
the end user:
27+
- DataManagement
28+
- Interfaces
29+
- ResourceStatus
30+
- StorageManagement
31+
- WorkloadManagement
32+
33+
It defines the following data members:
34+
- version: DIRAC version string
35+
36+
- errorMail: mail address for important errors
37+
- alarmMail: mail address for important alarms
38+
39+
It loads Modules from :
40+
- DIRAC.Core.Utililies
41+
42+
It loads:
43+
- S_OK: OK return structure
44+
- S_ERROR: ERROR return structure
45+
- gLogger: global Logger object
46+
- gConfig: global Config object
47+
48+
It defines the following functions:
49+
- abort: aborts execution
50+
- exit: finish execution using callbacks
51+
- siteName: returns DIRAC name for current site
52+
53+
- getPlatform(): DIRAC platform string for current host
54+
- getPlatformTuple(): DIRAC platform tuple for current host
5555
5656
"""
57+
5758
import importlib.metadata
5859
import os
5960
import re
@@ -237,7 +238,7 @@ def initialize(
237238
log_level = getattr(LogLevel, gLogger.getLevel())
238239
gLogger.setLevel(LogLevel.ALWAYS)
239240
try:
240-
returnValueOrRaise(localCfg.initialize())
241+
returnValueOrRaise(localCfg.initialize(requireSuccessfulSync=require_auth))
241242
finally:
242243
# Restore the pre-existing log level
243244
gLogger.setLevel(log_level)

0 commit comments

Comments
 (0)