Skip to content

Commit 988d007

Browse files
committed
fix: add a short proxy only at submission time
1 parent 7b85a48 commit 988d007

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -302,24 +302,6 @@ def _submitPilotsPerQueue(self, queueName: str):
302302
self.failedQueues[queueName] += 1
303303
return S_OK(0)
304304

305-
# Adjust queueCPUTime: needed to generate the proxy
306-
if "CPUTime" not in queueDictionary["ParametersDict"]:
307-
self.log.error("CPU time limit is not specified, skipping", f"queue {queueName}")
308-
return S_ERROR(f"CPU time limit is not specified, skipping queue {queueName}")
309-
310-
queueCPUTime = int(queueDictionary["ParametersDict"]["CPUTime"])
311-
if queueCPUTime > self.maxQueueLength:
312-
queueCPUTime = self.maxQueueLength
313-
314-
# Get CE instance
315-
ce = self.queueDict[queueName]["CE"]
316-
317-
# Set credentials
318-
result = self._setCredentials(ce, queueCPUTime)
319-
if not result["OK"]:
320-
self.log.error("Failed to set credentials:", result["Message"])
321-
return result
322-
323305
# Get the number of available slots on the target site/queue
324306
totalSlots, waitingPilots = self._getQueueSlots(queueName)
325307
if totalSlots <= 0:
@@ -340,6 +322,7 @@ def _submitPilotsPerQueue(self, queueName: str):
340322
)
341323

342324
# Now really submitting
325+
ce = self.queueDict[queueName]["CE"]
343326
result = self._submitPilotsToQueue(pilotsToSubmit, ce, queueName)
344327
if not result["OK"]:
345328
self.log.info("Failed pilot submission", f"Queue: {queueName}")
@@ -456,6 +439,12 @@ def _submitPilotsToQueue(self, pilotsToSubmit: int, ce: ComputingElement, queue:
456439
jobProxy = result["Value"]
457440
executable = self._getExecutable(queue, proxy=jobProxy, jobExecDir=jobExecDir, envVariables=envVariables)
458441

442+
# Add the credentials to the CE
443+
result = self._setCredentials(ce, 3600)
444+
if not result["OK"]:
445+
self.log.error("Failed to set credentials:", result["Message"])
446+
return result
447+
459448
# Submit the job
460449
submitResult = ce.submitJob(executable, "", pilotsToSubmit)
461450
# In case the CE does not need the executable after the submission, we delete it
@@ -900,20 +889,18 @@ def __supportToken(self, ce: ComputingElement) -> bool:
900889
return "Token" in ce.ceParameters.get("Tag", []) or f"Token:{self.vo}" in ce.ceParameters.get("Tag", [])
901890

902891
def _setCredentials(self, ce: ComputingElement, proxyMinimumRequiredValidity: int):
903-
"""
892+
"""Add a proxy and a token to the ComputingElement.
904893
905894
:param ce: ComputingElement instance
906895
:param proxyMinimumRequiredValidity: number of seconds needed to perform an operation with the proxy
907-
:param tokenMinimumRequiredValidity: number of seconds needed to perform an operation with the token
908896
"""
909897
getNewProxy = False
910898

911899
# If the CE does not already embed a proxy, we need one
912900
if not ce.proxy:
913901
getNewProxy = True
914-
915-
# If the CE embeds a proxy that is too short to perform a given operation, we need a new one
916-
if ce.proxy:
902+
else:
903+
# If the CE embeds a proxy that is too short to perform a given operation, we need a new one
917904
result = ce.proxy.getRemainingSecs()
918905
if not result["OK"]:
919906
return result

0 commit comments

Comments
 (0)