Skip to content

Commit

Permalink
fix: passing pilotDN instead of owner in getPilotProxyFromVOMSGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Aug 24, 2023
1 parent fa979a6 commit a63f9ff
Showing 1 changed file with 32 additions and 19 deletions.
51 changes: 32 additions & 19 deletions src/DIRAC/WorkloadManagementSystem/Service/WMSUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

from DIRAC import S_OK, S_ERROR, gLogger, gConfig
from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getQueue
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getGroupOption, getUsernameForDN, getVOForGroup
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import (
getDNForUsername,
getGroupOption,
getUsernameForDN,
getVOForGroup,
)
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
from DIRAC.FrameworkSystem.Client.TokenManagerClient import gTokenManager
Expand Down Expand Up @@ -56,13 +61,20 @@ def getPilotProxy(pilotDict):
:param dict pilotDict: pilot parameters
:return: S_OK/S_ERROR with proxy as Value
"""
ownerDN = pilotDict["OwnerDN"]
group = pilotDict["OwnerGroup"]

groupVOMS = getGroupOption(group, "VOMSRole", group)
result = gProxyManager.getPilotProxyFromVOMSGroup(ownerDN, groupVOMS)
pilotGroup = pilotDict["OwnerGroup"]

pilotDN = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotDN")
if not pilotDN:
owner = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotUser")
res = getDNForUsername(owner)
if not res["OK"]:
return S_ERROR(f"Cannot get the generic pilot DN: {res['Message']}")
pilotDN = res["Value"][0]

groupVOMS = getGroupOption(pilotGroup, "VOMSRole", pilotGroup)
result = gProxyManager.getPilotProxyFromVOMSGroup(pilotDN, groupVOMS)
if not result["OK"]:
gLogger.error("Could not get proxy:", f"User \"{ownerDN}\" Group \"{groupVOMS}\" : {result['Message']}")
gLogger.error("Could not get proxy:", f"User \"{pilotDN}\" Group \"{groupVOMS}\" : {result['Message']}")
return S_ERROR("Failed to get the pilot's owner proxy")
return result

Expand Down Expand Up @@ -124,19 +136,20 @@ def killPilotsInQueues(pilotRefDict):
ce = result["Value"]

pilotDN = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotDN")

if pilotGroup and pilotDN:
res = getUsernameForDN(pilotDN)
if not pilotDN:
owner = Operations(vo=getVOForGroup(pilotGroup)).getValue("Pilot/GenericPilotUser")
res = getDNForUsername(owner)
if not res["OK"]:
return res
owner = res["Value"]
group = getGroupOption(pilotGroup, "VOMSRole", pilotGroup)
ret = gProxyManager.getPilotProxyFromVOMSGroup(owner, group)
if not ret["OK"]:
gLogger.error("Could not get proxy:", f"User '{owner}' Group '{group}' : {ret['Message']}")
return S_ERROR("Failed to get the pilot's owner proxy")
proxy = ret["Value"]
ce.setProxy(proxy)
return S_ERROR(f"Cannot get the generic pilot DN: {res['Message']}")
pilotDN = res["Value"][0]

group = getGroupOption(pilotGroup, "VOMSRole", pilotGroup)
ret = gProxyManager.getPilotProxyFromVOMSGroup(pilotDN, group)
if not ret["OK"]:
gLogger.error("Could not get proxy:", f"User '{pilotDN}' Group '{group}' : {ret['Message']}")
return S_ERROR("Failed to get the pilot's owner proxy")
proxy = ret["Value"]
ce.setProxy(proxy)

pilotList = pilotDict["PilotList"]
result = ce.killJob(pilotList)
Expand Down

0 comments on commit a63f9ff

Please sign in to comment.