Skip to content

Commit 36c1b32

Browse files
committed
fix: more setup removals
1 parent f48deae commit 36c1b32

File tree

13 files changed

+48
-88
lines changed

13 files changed

+48
-88
lines changed

src/DIRAC/Core/Base/AgentModule.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
"""
22
Base class for all agent modules
33
"""
4+
import datetime
5+
import importlib.metadata
6+
import inspect
47
import os
8+
import signal
59
import threading
610
import time
7-
import signal
8-
import importlib.metadata
9-
import inspect
10-
import datetime
11+
1112
import psutil
1213

1314
import DIRAC
14-
from DIRAC import S_OK, S_ERROR, gConfig, gLogger, rootPath
15-
from DIRAC.Core.Utilities.File import mkDir
15+
from DIRAC import S_ERROR, S_OK, gConfig, gLogger, rootPath
16+
from DIRAC.ConfigurationSystem.Client import PathFinder
17+
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
1618
from DIRAC.Core.Utilities import Network, TimeUtilities
17-
from DIRAC.Core.Utilities.Shifter import setupShifterProxyInEnv
19+
from DIRAC.Core.Utilities.File import mkDir
1820
from DIRAC.Core.Utilities.ReturnValues import isReturnStructure
19-
from DIRAC.ConfigurationSystem.Client import PathFinder
21+
from DIRAC.Core.Utilities.Shifter import setupShifterProxyInEnv
2022
from DIRAC.Core.Utilities.ThreadScheduler import gThreadScheduler
21-
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
2223

2324

2425
class AgentModule:
@@ -68,7 +69,6 @@ def __init__(self, agentName, loadName, baseAgentName=False, properties={}):
6869
They are used to populate __codeProperties
6970
7071
The following Options are used from the Configuration:
71-
- /DIRAC/Setup
7272
- Status
7373
- Enabled
7474
- PollingTime default = 120
@@ -113,7 +113,6 @@ def __init__(self, agentName, loadName, baseAgentName=False, properties={}):
113113
"loadSection": PathFinder.getAgentSection(loadName),
114114
"cyclesDone": 0,
115115
"totalElapsedTime": 0,
116-
"setup": gConfig.getValue("/DIRAC/Setup", "Unknown"),
117116
"alive": True,
118117
}
119118
self.__moduleProperties["system"], self.__moduleProperties["agentName"] = agentName.split("/")
@@ -201,7 +200,6 @@ def am_initialize(self, *initArgs):
201200
self.log.notice("=" * 40)
202201
self.log.notice(f"Loaded agent module {self.__moduleProperties['fullName']}")
203202
self.log.notice(f" Site: {DIRAC.siteName()}")
204-
self.log.notice(f" Setup: {gConfig.getValue('/DIRAC/Setup')}")
205203
self.log.notice(f" Agent version: {self.__codeProperties['version']}")
206204
self.log.notice(f" DIRAC version: {DIRAC.version}")
207205
self.log.notice(f" DIRAC platform: {DIRAC.getPlatform()}")

src/DIRAC/Core/Base/ExecutorModule.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
Just provides a number of functions used by all executors
44
"""
55
import os
6-
from DIRAC import S_OK, S_ERROR, gConfig, gLogger, rootPath
6+
7+
from DIRAC import S_ERROR, S_OK, gConfig, gLogger, rootPath
78
from DIRAC.ConfigurationSystem.Client import PathFinder
8-
from DIRAC.Core.Utilities.Shifter import setupShifterProxyInEnv
99
from DIRAC.Core.Utilities.ReturnValues import isReturnStructure
10+
from DIRAC.Core.Utilities.Shifter import setupShifterProxyInEnv
1011

1112

1213
class ExecutorModule:
@@ -21,7 +22,6 @@ def _ex_initialize(cls, exeName, loadName):
2122
"loadSection": PathFinder.getExecutorSection(loadName),
2223
"messagesProcessed": 0,
2324
"reconnects": 0,
24-
"setup": gConfig.getValue("/DIRAC/Setup", "Unknown"),
2525
}
2626
cls.__defaults = {}
2727
cls.__defaults["MonitoringEnabled"] = True

src/DIRAC/DataManagementSystem/scripts/dirac_admin_allow_se.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def main():
5050
site = switch[1]
5151

5252
# imports
53-
from DIRAC import gConfig, gLogger
53+
from DIRAC import gLogger
5454
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
5555
from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSites
5656
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
@@ -68,11 +68,6 @@ def main():
6868

6969
ses = resolveSEGroup(ses)
7070
diracAdmin = DiracAdmin()
71-
errorList = []
72-
setup = gConfig.getValue("/DIRAC/Setup", "")
73-
if not setup:
74-
print("ERROR: Could not contact Configuration Service")
75-
DIRAC.exit(2)
7671

7772
res = getProxyInfo()
7873
if not res["OK"]:

src/DIRAC/DataManagementSystem/scripts/dirac_admin_ban_se.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,15 @@ def main():
5858
sites = switch[1].split(",")
5959

6060
# from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI
61-
from DIRAC import gConfig, gLogger
61+
from DIRAC import gLogger
6262
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
6363
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
64+
from DIRAC.DataManagementSystem.Utilities.DMSHelpers import DMSHelpers, resolveSEGroup
6465
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
6566
from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus
66-
from DIRAC.DataManagementSystem.Utilities.DMSHelpers import resolveSEGroup, DMSHelpers
6767

6868
ses = resolveSEGroup(ses)
6969
diracAdmin = DiracAdmin()
70-
setup = gConfig.getValue("/DIRAC/Setup", "")
71-
if not setup:
72-
print("ERROR: Could not contact Configuration Service")
73-
DIRAC.exit(2)
7470

7571
res = getProxyInfo()
7672
if not res["OK"]:

src/DIRAC/Interfaces/scripts/dirac_admin_allow_site.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ def main():
2222
Script.registerArgument("Comment: Reason of the action")
2323
Script.parseCommandLine(ignoreErrors=True)
2424

25-
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
25+
from DIRAC import exit as DIRACExit
26+
from DIRAC import gLogger
2627
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
27-
from DIRAC import exit as DIRACExit, gConfig, gLogger
28+
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
2829

2930
def getBoolean(value):
3031
if value.lower() == "true":
@@ -42,11 +43,6 @@ def getBoolean(value):
4243
diracAdmin = DiracAdmin()
4344
exitCode = 0
4445
errorList = []
45-
setup = gConfig.getValue("/DIRAC/Setup", "")
46-
if not setup:
47-
print("ERROR: Could not contact Configuration Service")
48-
exitCode = 2
49-
DIRACExit(exitCode)
5046

5147
# result = promptUser(
5248
# 'All the elements that are associated with this site will be active, '
@@ -70,10 +66,9 @@ def getBoolean(value):
7066
exitCode = 2
7167
DIRACExit(exitCode)
7268
userName = userName["Value"]
73-
subject = f"{site} is added in site mask for {setup} setup"
74-
body = "Site {} is added to the site mask for {} setup by {} on {}.\n\n".format(
69+
subject = f"{site} is added in site mask"
70+
body = "Site {} is added to the site mask by {} on {}.\n\n".format(
7571
site,
76-
setup,
7772
userName,
7873
time.asctime(),
7974
)

src/DIRAC/Interfaces/scripts/dirac_admin_ban_site.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def main():
2222
Script.registerArgument("Comment: Reason of the action")
2323
Script.parseCommandLine(ignoreErrors=True)
2424

25-
from DIRAC import exit as DIRACExit, gConfig, gLogger
26-
from DIRAC.Core.Utilities.PromptUser import promptUser
27-
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
25+
from DIRAC import exit as DIRACExit
26+
from DIRAC import gLogger
2827
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
28+
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
2929

3030
def getBoolean(value):
3131
if value.lower() == "true":
@@ -43,11 +43,6 @@ def getBoolean(value):
4343
diracAdmin = DiracAdmin()
4444
exitCode = 0
4545
errorList = []
46-
setup = gConfig.getValue("/DIRAC/Setup", "")
47-
if not setup:
48-
print("ERROR: Could not contact Configuration Service")
49-
exitCode = 2
50-
DIRACExit(exitCode)
5146

5247
# result = promptUser(
5348
# 'All the elements that are associated with this site will be banned,'
@@ -71,10 +66,9 @@ def getBoolean(value):
7166
exitCode = 2
7267
DIRACExit(exitCode)
7368
userName = userName["Value"]
74-
subject = f"{site} is banned for {setup} setup"
75-
body = "Site {} is removed from site mask for {} setup by {} on {}.\n\n".format(
69+
subject = f"{site} is banned"
70+
body = "Site {} is removed from site mask by {} on {}.\n\n".format(
7671
site,
77-
setup,
7872
userName,
7973
time.asctime(),
8074
)

src/DIRAC/Resources/Computing/SingularityComputingElement.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ def __getInstallFlags(self, infoDict=None):
175175
setup = infoDict.get("DefaultSetup")
176176
if not setup:
177177
setup = list(infoDict.get("Setups"))[0]
178-
if not setup:
179-
setup = gConfig.getValue("/DIRAC/Setup", "unknown")
180178
setup = str(setup)
181179

182180
diracProject = "DIRAC"
@@ -205,8 +203,6 @@ def __getConfigFlags(infoDict=None):
205203
cfgOpts = []
206204

207205
setup = infoDict.get("DefaultSetup")
208-
if not setup:
209-
setup = gConfig.getValue("/DIRAC/Setup", "unknown")
210206
cfgOpts.append(f"-S '{setup}'")
211207

212208
csServers = infoDict.get("ConfigurationServers")

src/DIRAC/WorkloadManagementSystem/Agent/PushJobAgent.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -571,13 +571,6 @@ def _submitJobWrapper(
571571
# Dump the remote CFG config into the job directory: it is needed for the JobWrapperTemplate
572572
cfgFilename = Path(job.jobIDPath) / "dirac.cfg"
573573
gConfig.dumpRemoteCFGToFile(cfgFilename)
574-
# -----------------------------------------------------------------------------------------------
575-
# Temporary hack: in v9.0, the DIRAC/Setup is meant to be removed from the configuration
576-
# Until then, we need to set it manually
577-
cfg = CFG().loadFromFile(cfgFilename)
578-
cfg.setOption("DIRAC/Setup", gConfig.getOption("DIRAC/Setup", "")["Value"])
579-
cfg.writeToFile(cfgFilename)
580-
# -----------------------------------------------------------------------------------------------
581574

582575
# Generate a light JobWrapper executor script
583576
jobDesc = {

src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,7 @@ def _getPilotOptions(self, queue: str) -> list[str]:
610610
queueDict = self.queueDict[queue]["ParametersDict"]
611611
pilotOptions = []
612612

613-
setup = gConfig.getValue("/DIRAC/Setup", "unknown")
614-
if setup == "unknown":
615-
self.log.error("Setup is not defined in the configuration")
616-
return []
617-
pilotOptions.append(f"-S {setup}")
618-
opsHelper = Operations(vo=self.vo, setup=setup)
613+
opsHelper = Operations(vo=self.vo)
619614

620615
# Installation defined?
621616
installationName = opsHelper.getValue("Pilot/Installation", "")

src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_SiteDirector.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212
from DIRAC import S_OK, gConfig, gLogger
1313
from DIRAC.ConfigurationSystem.Client import ConfigurationData
14-
from DIRAC.ResourceStatusSystem.Client.SiteStatus import SiteStatus
1514
from DIRAC.ResourceStatusSystem.Client.ResourceStatus import ResourceStatus
16-
15+
from DIRAC.ResourceStatusSystem.Client.SiteStatus import SiteStatus
1716
from DIRAC.WorkloadManagementSystem.Agent.SiteDirector import SiteDirector
1817
from DIRAC.WorkloadManagementSystem.Client import PilotStatus
1918

@@ -258,7 +257,6 @@ def test_getNumberOfJobsNeedingPilots(sd, mocker):
258257

259258
def test_getPilotWrapper(mocker, sd, pilotWrapperDirectory):
260259
"""Get pilot options for a specific queue and check the result, then generate the pilot wrapper"""
261-
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gConfig.getValue", return_value="TestSetup")
262260

263261
# Get pilot options
264262
pilotOptions = sd._getPilotOptions("ce1.site1.com_condor")
@@ -268,7 +266,6 @@ def test_getPilotWrapper(mocker, sd, pilotWrapperDirectory):
268266
"-n LCG.Site1.com",
269267
"-N ce1.site1.com",
270268
"-Q condor",
271-
"-S TestSetup",
272269
"-V 123",
273270
"-l 123",
274271
"-e 1,2,3",

0 commit comments

Comments
 (0)