Skip to content

Commit e6aea11

Browse files
committed
feat: PilotAgentsDB: remove DN
1 parent 23b7407 commit e6aea11

File tree

7 files changed

+32
-80
lines changed

7 files changed

+32
-80
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,6 @@ def _addPilotTQReference(self, queue, taskQueueDict, pilotList, stampDict):
841841
result = self.pilotAgentsDB.addPilotTQReference(
842842
pilotsList,
843843
tqID,
844-
self.pilotDN,
845844
self.pilotGroup,
846845
self.localhost,
847846
self.queueDict[queue]["CEType"],
@@ -1201,7 +1200,6 @@ def _updatePilotStatusPerQueue(self, queue, proxy):
12011200
"GridType": ceType,
12021201
"GridSite": siteName,
12031202
"Status": PilotStatus.PILOT_TRANSIENT_STATES,
1204-
"OwnerDN": self.pilotDN,
12051203
"OwnerGroup": self.pilotGroup,
12061204
}
12071205
)

src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.py

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import DIRAC.Core.Utilities.TimeUtilities as TimeUtilities
2525
from DIRAC import S_ERROR, S_OK
26-
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getDNForUsername, getUsernameForDN, getVOForGroup
26+
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getVOForGroup
2727
from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getCESiteMapping
2828
from DIRAC.Core.Base.DB import DB
2929
from DIRAC.Core.Utilities import DErrno
@@ -39,7 +39,7 @@ def __init__(self, parentLogger=None):
3939

4040
##########################################################################################
4141
def addPilotTQReference(
42-
self, pilotRef, taskQueueID, ownerDN, ownerGroup, broker="Unknown", gridType="DIRAC", pilotStampDict={}
42+
self, pilotRef, taskQueueID, ownerGroup, broker="Unknown", gridType="DIRAC", pilotStampDict={}
4343
):
4444
"""Add a new pilot job reference"""
4545

@@ -50,16 +50,11 @@ def addPilotTQReference(
5050
if ref in pilotStampDict:
5151
stamp = pilotStampDict[ref]
5252

53-
res = self._escapeString(ownerDN)
54-
if not res["OK"]:
55-
return res
56-
escapedOwnerDN = res["Value"]
57-
5853
req = (
59-
"INSERT INTO PilotAgents( PilotJobReference, TaskQueueID, OwnerDN, "
54+
"INSERT INTO PilotAgents( PilotJobReference, TaskQueueID, "
6055
+ "OwnerGroup, Broker, GridType, SubmissionTime, LastUpdateTime, Status, PilotStamp ) "
61-
+ "VALUES ('%s',%d,%s,'%s','%s','%s',UTC_TIMESTAMP(),UTC_TIMESTAMP(),'Submitted','%s')"
62-
% (ref, int(taskQueueID), escapedOwnerDN, ownerGroup, broker, gridType, stamp)
56+
+ "VALUES ('%s',%d,'%s','%s','%s',UTC_TIMESTAMP(),UTC_TIMESTAMP(),'Submitted','%s')"
57+
% (ref, int(taskQueueID), ownerGroup, broker, gridType, stamp)
6358
)
6459

6560
result = self._update(req)
@@ -186,7 +181,7 @@ def countPilots(self, condDict, older=None, newer=None, timeStamp="SubmissionTim
186181
return S_OK(result["Value"][0][0])
187182

188183
#########################################################################################
189-
def getPilotGroups(self, groupList=["Status", "OwnerDN", "OwnerGroup", "GridType"], condDict={}):
184+
def getPilotGroups(self, groupList=["Status", "OwnerGroup", "GridType"], condDict={}):
190185
"""
191186
Get all exisiting combinations of groupList Values
192187
"""
@@ -275,7 +270,6 @@ def getPilotInfo(self, pilotRef=False, parentId=False, conn=False, paramNames=[]
275270
parameters = (
276271
[
277272
"PilotJobReference",
278-
"OwnerDN",
279273
"OwnerGroup",
280274
"GridType",
281275
"Broker",
@@ -1030,7 +1024,7 @@ def getPilotSummaryWeb(self, selectDict, sortList, startItem, maxItems):
10301024
def getPilotMonitorSelectors(self):
10311025
"""Get distinct values for the Pilot Monitor page selectors"""
10321026

1033-
paramNames = ["OwnerDN", "OwnerGroup", "GridType", "Broker", "Status", "DestinationSite", "GridSite"]
1027+
paramNames = ["OwnerGroup", "GridType", "Broker", "Status", "DestinationSite", "GridSite"]
10341028

10351029
resultDict = {}
10361030
for param in paramNames:
@@ -1040,14 +1034,6 @@ def getPilotMonitorSelectors(self):
10401034
else:
10411035
resultDict = []
10421036

1043-
if param == "OwnerDN":
1044-
userList = []
1045-
for dn in result["Value"]:
1046-
resultUser = getUsernameForDN(dn)
1047-
if resultUser["OK"]:
1048-
userList.append(resultUser["Value"])
1049-
resultDict["Owner"] = userList
1050-
10511037
return S_OK(resultDict)
10521038

10531039
##########################################################################################
@@ -1057,16 +1043,7 @@ def getPilotMonitorWeb(self, selectDict, sortList, startItem, maxItems):
10571043
resultDict = {}
10581044
if "LastUpdateTime" in selectDict:
10591045
del selectDict["LastUpdateTime"]
1060-
if "Owner" in selectDict:
1061-
userList = selectDict["Owner"]
1062-
if not isinstance(userList, list):
1063-
userList = [userList]
1064-
dnList = []
1065-
for uName in userList:
1066-
uList = getDNForUsername(uName)["Value"]
1067-
dnList += uList
1068-
selectDict["OwnerDN"] = dnList
1069-
del selectDict["Owner"]
1046+
10701047
startDate = selectDict.get("FromDate", None)
10711048
if startDate:
10721049
del selectDict["FromDate"]
@@ -1108,7 +1085,6 @@ def getPilotMonitorWeb(self, selectDict, sortList, startItem, maxItems):
11081085

11091086
paramNames = [
11101087
"PilotJobReference",
1111-
"OwnerDN",
11121088
"OwnerGroup",
11131089
"GridType",
11141090
"Broker",

src/DIRAC/WorkloadManagementSystem/DB/PilotAgentsDB.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ CREATE TABLE `PilotAgents` (
3636
`Queue` VARCHAR(128) NOT NULL DEFAULT 'Unknown',
3737
`GridSite` VARCHAR(128) NOT NULL DEFAULT 'Unknown',
3838
`Broker` VARCHAR(128) NOT NULL DEFAULT 'Unknown',
39-
`OwnerDN` VARCHAR(255) NOT NULL,
4039
`OwnerGroup` VARCHAR(128) NOT NULL,
4140
`GridType` VARCHAR(32) NOT NULL DEFAULT 'LCG',
4241
`GridRequirements` TEXT,

src/DIRAC/WorkloadManagementSystem/Service/PilotManagerHandler.py

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from DIRAC import S_OK, S_ERROR
88
import DIRAC.Core.Utilities.TimeUtilities as TimeUtilities
99

10+
from DIRAC.ConfigurationSystem.Client.Helpers import Registry
11+
from DIRAC.Core.Utilities.Decorators import deprecated
1012
from DIRAC.Core.DISET.RequestHandler import RequestHandler
1113
from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader
1214
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getUsernameForDN, getDNForUsername
@@ -70,13 +72,24 @@ def export_getCurrentPilotCounters(cls, attrDict={}):
7072
##########################################################################################
7173
types_addPilotTQReference = [list, int, str, str]
7274

75+
@deprecated("Use addPilotTQRef")
7376
@classmethod
7477
def export_addPilotTQReference(
7578
cls, pilotRef, taskQueueID, ownerDN, ownerGroup, broker="Unknown", gridType="DIRAC", pilotStampDict={}
7679
):
7780
"""Add a new pilot job reference"""
81+
82+
return cls.pilotAgentsDB.addPilotTQReference(pilotRef, taskQueueID, ownerGroup, gridType, pilotStampDict)
83+
84+
types_addPilotTQRef = [list, int, str, str]
85+
86+
@classmethod
87+
def export_addPilotTQRef(
88+
cls, pilotRef, taskQueueID, ownerGroup, broker="Unknown", gridType="DIRAC", pilotStampDict={}
89+
):
90+
"""Add a new pilot job reference"""
7891
return cls.pilotAgentsDB.addPilotTQReference(
79-
pilotRef, taskQueueID, ownerDN, ownerGroup, broker, gridType, pilotStampDict
92+
pilotRef, taskQueueID, ownerGroup, broker, gridType, pilotStampDict
8093
)
8194

8295
##############################################################################
@@ -96,7 +109,6 @@ def export_getPilotOutput(self, pilotReference):
96109

97110
pilotDict = result["Value"][pilotReference]
98111

99-
ownerDN = pilotDict["OwnerDN"]
100112
group = pilotDict["OwnerGroup"]
101113

102114
# FIXME: What if the OutputSandBox is not StdOut and StdErr, what do we do with other files?
@@ -108,7 +120,6 @@ def export_getPilotOutput(self, pilotReference):
108120
resultDict = {}
109121
resultDict["StdOut"] = stdout
110122
resultDict["StdErr"] = error
111-
resultDict["OwnerDN"] = ownerDN
112123
resultDict["OwnerGroup"] = group
113124
resultDict["FileList"] = []
114125
return S_OK(resultDict)
@@ -146,7 +157,6 @@ def export_getPilotOutput(self, pilotReference):
146157
resultDict = {}
147158
resultDict["StdOut"] = stdout
148159
resultDict["StdErr"] = error
149-
resultDict["OwnerDN"] = ownerDN
150160
resultDict["OwnerGroup"] = group
151161
resultDict["FileList"] = []
152162
shutil.rmtree(ce.ceParameters["WorkingDirectory"])
@@ -325,19 +335,16 @@ def export_killPilot(cls, pilotRefList):
325335
if isinstance(pilotRefList, str):
326336
pilotRefs = [pilotRefList]
327337

328-
# Regroup pilots per site and per ownerDN
338+
# Regroup pilots per site
329339
pilotRefDict = {}
330340
for pilotReference in pilotRefs:
331341
result = cls.pilotAgentsDB.getPilotInfo(pilotReference)
332342
if not result["OK"] or not result["Value"]:
333343
return S_ERROR("Failed to get info for pilot " + pilotReference)
334344

335345
pilotDict = result["Value"][pilotReference]
336-
ownerDN = pilotDict["OwnerDN"]
337346
group = pilotDict["OwnerGroup"]
338-
queue = "@@@".join(
339-
[ownerDN, group, pilotDict["GridSite"], pilotDict["DestinationSite"], pilotDict["Queue"]]
340-
)
347+
queue = "@@@".join([group, pilotDict["GridSite"], pilotDict["DestinationSite"], pilotDict["Queue"]])
341348
gridType = pilotDict["GridType"]
342349
pilotRefDict.setdefault(queue, {})
343350
pilotRefDict[queue].setdefault("PilotList", [])
@@ -428,33 +435,13 @@ def export_getPilotStatistics(cls, attribute, selectDict):
428435
if endDate:
429436
del selectDict["ToDate"]
430437

431-
# Owner attribute is not part of PilotAgentsDB
432-
# It has to be converted into a OwnerDN
433-
owners = selectDict.get("Owner")
434-
if owners:
435-
ownerDNs = []
436-
for owner in owners:
437-
result = getDNForUsername(owner)
438-
if not result["OK"]:
439-
return result
440-
ownerDNs.append(result["Value"])
441-
442-
selectDict["OwnerDN"] = ownerDNs
443-
del selectDict["Owner"]
444-
445438
result = cls.pilotAgentsDB.getCounters(
446439
"PilotAgents", [attribute], selectDict, newer=startDate, older=endDate, timeStamp="LastUpdateTime"
447440
)
448441
statistics = {}
449442
if result["OK"]:
450443
for status, count in result["Value"]:
451-
if "OwnerDN" in status:
452-
userName = getUsernameForDN(status["OwnerDN"])
453-
if userName["OK"]:
454-
status["OwnerDN"] = userName["Value"]
455-
statistics[status["OwnerDN"]] = count
456-
else:
457-
statistics[status[attribute]] = count
444+
statistics[status[attribute]] = count
458445

459446
return S_OK(statistics)
460447

src/DIRAC/WorkloadManagementSystem/scripts/dirac_admin_add_pilot.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
This script is here to solve specifically this issue, even though it can be used for other things too.
99
1010
Example:
11-
$ dirac-admin-add-pilot htcondor:123456 user_DN user_group DIRAC A11D8D2E-60F8-17A6-5520-E2276F41 --Status=Running
11+
$ dirac-admin-add-pilot htcondor:123456 user user_group DIRAC A11D8D2E-60F8-17A6-5520-E2276F41 --Status=Running
1212
1313
"""
1414

@@ -67,15 +67,14 @@ def main():
6767

6868
Script.registerSwitches(params.switches)
6969
Script.registerArgument("pilotRef: pilot reference")
70-
Script.registerArgument("ownerDN: pilot owner DN")
7170
Script.registerArgument("ownerGroup: pilot owner group")
7271
Script.registerArgument("gridType: grid type")
7372
Script.registerArgument("pilotStamp: DIRAC pilot stamp")
7473

7574
Script.parseCommandLine(ignoreErrors=False)
7675

7776
# Get grouped positional arguments
78-
pilotRef, ownerDN, ownerGroup, gridType, pilotStamp = Script.getPositionalArgs(group=True)
77+
pilotRef, ownerGroup, gridType, pilotStamp = Script.getPositionalArgs(group=True)
7978

8079
# Import the required DIRAC modules
8180
from DIRAC.Core.Utilities import DErrno
@@ -89,9 +88,7 @@ def main():
8988
if not DErrno.cmpError(res, DErrno.EWMSNOPILOT):
9089
gLogger.error(res["Message"])
9190
DIRACExit(1)
92-
res = pmc.addPilotTQReference(
93-
[pilotRef], params.taskQueueID, ownerDN, ownerGroup, "Unknown", gridType, {pilotRef: pilotStamp}
94-
)
91+
res = pmc.addPilotTQRef([pilotRef], params.taskQueueID, ownerGroup, "Unknown", gridType, {pilotRef: pilotStamp})
9592
if not res["OK"]:
9693
gLogger.error(res["Message"])
9794
DIRACExit(1)

tests/Integration/WorkloadManagementSystem/Test_PilotAgentsDB.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def preparePilots(stateCount, testSite, testCE, testGroup):
3939
res = paDB.addPilotTQReference(
4040
pilotRef,
4141
123,
42-
"ownerDN",
4342
testGroup,
4443
)
4544
assert res["OK"] is True, res["Message"]
@@ -84,7 +83,6 @@ def test_basic():
8483
res = paDB.addPilotTQReference(
8584
["pilotRef"],
8685
123,
87-
"ownerDN",
8886
"ownerGroup",
8987
)
9088
assert res["OK"] is True

tests/Integration/WorkloadManagementSystem/Test_PilotsClient.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_PilotsDB():
2727
for jobID in ["aPilot", "anotherPilot"]:
2828
pilots.deletePilots(jobID)
2929

30-
res = pilots.addPilotTQReference(["aPilot"], 1, "/a/ownerDN", "a/owner/Group")
30+
res = pilots.addPilotTQRef(["aPilot"], 1, "ownerGroup")
3131
assert res["OK"], res["Message"]
3232
res = pilots.getCurrentPilotCounters({})
3333
assert res["OK"], res["Message"]
@@ -38,15 +38,14 @@ def test_PilotsDB():
3838
assert res["OK"], res["Message"]
3939
assert res["Value"] == {}
4040

41-
res = pilots.addPilotTQReference(["anotherPilot"], 1, "/a/ownerDN", "a/owner/Group")
41+
res = pilots.addPilotTQRef(["anotherPilot"], 1, "ownerGroup")
4242
assert res["OK"], res["Message"]
4343
res = pilots.storePilotOutput("anotherPilot", "This is an output", "this is an error")
4444
assert res["OK"], res["Message"]
4545
res = pilots.getPilotOutput("anotherPilot")
4646
assert res["OK"], res["Message"]
4747
assert res["Value"] == {
48-
"OwnerDN": "/a/ownerDN",
49-
"OwnerGroup": "a/owner/Group",
48+
"OwnerGroup": "ownerGroup",
5049
"StdErr": "this is an error",
5150
"FileList": [],
5251
"StdOut": "This is an output",
@@ -68,13 +67,11 @@ def test_PilotsDB():
6867
assert res["OK"], res["Message"]
6968
assert res["Value"] == {
7069
"GridType": ["DIRAC"],
71-
"OwnerGroup": ["a/owner/Group"],
70+
"OwnerGroup": ["ownerGroup"],
7271
"DestinationSite": ["NotAssigned"],
7372
"Broker": ["Unknown"],
7473
"Status": ["Submitted"],
75-
"OwnerDN": ["/a/ownerDN"],
7674
"GridSite": ["Unknown"],
77-
"Owner": [],
7875
}
7976
res = pilots.getPilotSummaryWeb({}, [], 0, 100)
8077
assert res["OK"], res["Message"]

0 commit comments

Comments
 (0)