Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.1] hacktathon fix: passing pilotDN instead of owner in getPilotProxyFromVOMSGroup() #7180

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions src/DIRAC/WorkloadManagementSystem/Service/WMSUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

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,
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 +60,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 +135,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
Loading