Skip to content

Commit 1de9b3d

Browse files
committed
fix: passing pilotDN instead of owner in getPilotProxyFromVOMSGroup
1 parent fa979a6 commit 1de9b3d

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

src/DIRAC/WorkloadManagementSystem/Service/WMSUtilities.py

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
from DIRAC import S_OK, S_ERROR, gLogger, gConfig
88
from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getQueue
9-
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getGroupOption, getUsernameForDN, getVOForGroup
9+
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import (
10+
getDNForUsername,
11+
getGroupOption,
12+
getVOForGroup,
13+
)
1014
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
1115
from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
1216
from DIRAC.FrameworkSystem.Client.TokenManagerClient import gTokenManager
@@ -56,13 +60,20 @@ def getPilotProxy(pilotDict):
5660
:param dict pilotDict: pilot parameters
5761
:return: S_OK/S_ERROR with proxy as Value
5862
"""
59-
ownerDN = pilotDict["OwnerDN"]
60-
group = pilotDict["OwnerGroup"]
61-
62-
groupVOMS = getGroupOption(group, "VOMSRole", group)
63-
result = gProxyManager.getPilotProxyFromVOMSGroup(ownerDN, groupVOMS)
63+
pilotGroup = pilotDict["OwnerGroup"]
64+
65+
pilotDN = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotDN")
66+
if not pilotDN:
67+
owner = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotUser")
68+
res = getDNForUsername(owner)
69+
if not res["OK"]:
70+
return S_ERROR(f"Cannot get the generic pilot DN: {res['Message']}")
71+
pilotDN = res["Value"][0]
72+
73+
groupVOMS = getGroupOption(pilotGroup, "VOMSRole", pilotGroup)
74+
result = gProxyManager.getPilotProxyFromVOMSGroup(pilotDN, groupVOMS)
6475
if not result["OK"]:
65-
gLogger.error("Could not get proxy:", f"User \"{ownerDN}\" Group \"{groupVOMS}\" : {result['Message']}")
76+
gLogger.error("Could not get proxy:", f"User \"{pilotDN}\" Group \"{groupVOMS}\" : {result['Message']}")
6677
return S_ERROR("Failed to get the pilot's owner proxy")
6778
return result
6879

@@ -124,19 +135,20 @@ def killPilotsInQueues(pilotRefDict):
124135
ce = result["Value"]
125136

126137
pilotDN = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotDN")
127-
128-
if pilotGroup and pilotDN:
129-
res = getUsernameForDN(pilotDN)
138+
if not pilotDN:
139+
owner = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotUser")
140+
res = getDNForUsername(owner)
130141
if not res["OK"]:
131-
return res
132-
owner = res["Value"]
133-
group = getGroupOption(pilotGroup, "VOMSRole", pilotGroup)
134-
ret = gProxyManager.getPilotProxyFromVOMSGroup(owner, group)
135-
if not ret["OK"]:
136-
gLogger.error("Could not get proxy:", f"User '{owner}' Group '{group}' : {ret['Message']}")
137-
return S_ERROR("Failed to get the pilot's owner proxy")
138-
proxy = ret["Value"]
139-
ce.setProxy(proxy)
142+
return S_ERROR(f"Cannot get the generic pilot DN: {res['Message']}")
143+
pilotDN = res["Value"][0]
144+
145+
group = getGroupOption(pilotGroup, "VOMSRole", pilotGroup)
146+
ret = gProxyManager.getPilotProxyFromVOMSGroup(pilotDN, group)
147+
if not ret["OK"]:
148+
gLogger.error("Could not get proxy:", f"User '{pilotDN}' Group '{group}' : {ret['Message']}")
149+
return S_ERROR("Failed to get the pilot's owner proxy")
150+
proxy = ret["Value"]
151+
ce.setProxy(proxy)
140152

141153
pilotList = pilotDict["PilotList"]
142154
result = ce.killJob(pilotList)

0 commit comments

Comments
 (0)