Skip to content

Commit

Permalink
feat: Download files with a shifter proxy, not the client one
Browse files Browse the repository at this point in the history
  • Loading branch information
martynia committed Aug 15, 2023
1 parent 1639db7 commit 98a1272
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def __init__(self):
"""
self.setup = gConfig.getValue("/DIRAC/Setup", None)

@executeWithUserProxy
def getRemotePilotLogs(self, pilotStamp, vo=None):
"""
Pilot log getter method, carrying the unique pilot identity and a VO name.
Expand All @@ -42,7 +41,21 @@ def getRemotePilotLogs(self, pilotStamp, vo=None):
sLog.info("LFN to download: ", lfn)
filepath = tempfile.TemporaryDirectory().name
os.makedirs(filepath, exist_ok=True)
res = DataManager().getFile(lfn, destinationDir=filepath)
# get pilot credentials which uploaded logs to an external storage:
res = opsHelper.getOptionsDict("Shifter/DataManager")
if not res["OK"]:
message = f"No shifter defined for VO: {vo} - needed to retrieve the logs !"
sLog.error(message)
return S_ERROR(message)

proxyUser = res["Value"].get("User")
proxyGroup = res["Value"].get("Group")

sLog.info(f"Proxy used for retrieving pilot logs: VO: {vo}, User: {proxyUser}, Group: {proxyGroup}")

res = self._downloadLogs(
lfn, filepath, proxyUserName=proxyUser, proxyUserGroup=proxyGroup
) # pylint: disable=unexpected-keyword-arg
sLog.debug("getFile result:", res)
if not res["OK"]:
sLog.error(f"Failed to contact storage")
Expand All @@ -61,3 +74,7 @@ def getRemotePilotLogs(self, pilotStamp, vo=None):
resultDict = {}
resultDict["StdOut"] = stdout
return S_OK(resultDict)

@executeWithUserProxy
def _downloadLogs(self, lfn, filepath):
return DataManager().getFile(lfn, destinationDir=filepath)

0 comments on commit 98a1272

Please sign in to comment.