From 98a1272bf03640e24bcf58eea43f96671022d5a2 Mon Sep 17 00:00:00 2001 From: Janusz Martyniak Date: Tue, 15 Aug 2023 12:22:37 +0200 Subject: [PATCH] feat: Download files with a shifter proxy, not the client one --- .../FileCacheDownloadPlugin.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/DIRAC/WorkloadManagementSystem/Client/PilotLoggingPlugins/FileCacheDownloadPlugin.py b/src/DIRAC/WorkloadManagementSystem/Client/PilotLoggingPlugins/FileCacheDownloadPlugin.py index ca16cabd9ca..2b2a271d6f7 100644 --- a/src/DIRAC/WorkloadManagementSystem/Client/PilotLoggingPlugins/FileCacheDownloadPlugin.py +++ b/src/DIRAC/WorkloadManagementSystem/Client/PilotLoggingPlugins/FileCacheDownloadPlugin.py @@ -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. @@ -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") @@ -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)