diff --git a/src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py b/src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py index d77e109b807..b67c2c7eb59 100644 --- a/src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py +++ b/src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py @@ -84,6 +84,9 @@ def __init__(self, *args, **kwargs): self.workingDirectory = None self.maxQueueLength = 86400 * 3 + # Bundle proxy lifetime factor: Job bundled proxy lifetime will be this multiplied by the queue runtime length, + # should be high enough to accommodate the queuing time of the job. + self.bundleProxyLifetimeFactor = 1.5 def initialize(self): """Initial settings""" @@ -446,7 +449,16 @@ def _submitPilotsToQueue(self, pilotsToSubmit: int, ce: ComputingElement, queue: envVariables = self.queueDict[queue]["ParametersDict"].get("EnvironmentVariables", None) # Generate the executable - executable = self._getExecutable(queue, proxy=ce.proxy, jobExecDir=jobExecDir, envVariables=envVariables) + # We don't want to use the submission/"pilot" proxy for the job in the bundle: + # Instead we use a non-VOMS proxy which is then not limited in lifetime by the VOMS extension + proxyTimeSec = int(self.maxQueueLength * self.bundleProxyLifetimeFactor) + pilotGroup = Operations(vo=self.vo).getValue("Pilot/GenericPilotGroup") + result = gProxyManager.downloadProxy(self.pilotDN, pilotGroup, limited=True, requiredTimeLeft=proxyTimeSec) + if not result["OK"]: + self.log.error("Failed to get job proxy", f"Queue {queue}:\n{result['Message']}") + return result + jobProxy = result["Value"] + executable = self._getExecutable(queue, proxy=jobProxy, jobExecDir=jobExecDir, envVariables=envVariables) # Submit the job submitResult = ce.submitJob(executable, "", pilotsToSubmit) diff --git a/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_SiteDirector.py b/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_SiteDirector.py index 8dde1108327..a961206bcfa 100644 --- a/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_SiteDirector.py +++ b/src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_SiteDirector.py @@ -144,6 +144,11 @@ } """ +mockPMProxy = MagicMock() +mockPMProxy.dumpAllToString.return_value = {"OK": True, "Value": "fakeProxy"} +mockPMProxyReply = MagicMock() +mockPMProxyReply.return_value = {"OK": True, "Value": mockPMProxy} + @pytest.fixture def config(): @@ -170,6 +175,9 @@ def sd(mocker, config): mocker.patch( "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.ResourceStatus.getElementStatus", return_values=usableSites ) + mocker.patch( + "DIRAC.WorkloadManagementSystem.Agent.SiteDirector.gProxyManager.downloadProxy", side_effect=mockPMProxyReply + ) sd = SiteDirector() # Set logger