Skip to content

Commit 415f953

Browse files
authored
Merge pull request #8184 from aldbr/main_FIX_pja-diracx-token
[9.0] fix(wms): PushJobAgent dumps the proxy to get access to DiracX token
2 parents 08562b8 + 1ab6572 commit 415f953

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/PushJobAgent.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,12 @@ def execute(self):
230230
return result
231231
pilotProxy = result["Value"]
232232

233+
# Dump the proxy to a file to get DiracX token (it's later used by DiracX)
234+
result = gProxyManager.dumpProxyToFile(pilotProxy)
235+
if not result["OK"]:
236+
return result
237+
os.environ["X509_USER_PROXY"] = result["Value"]
238+
233239
for queueName, queueDictionary in queueDictItems:
234240
# Make sure there is no problem with the queue before trying to submit
235241
if not self._allowedToSubmit(queueName):

src/DIRAC/WorkloadManagementSystem/Utilities/RemoteRunner.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ def execute(self, command, workingDirectory=".", numberOfProcessors=1, cleanRemo
4949
f"site {self._workloadSite}, CE {self._workloadCE}, queue {self._workloadQueue}",
5050
)
5151

52+
# The CE interface needs to drop the token section from the proxy file to interact with the CE
53+
# So we save the current proxy file location (which likely contains the DiracX token)
54+
# and we will restore it at the end of the job
55+
originalProxyLocation = os.environ.get("X509_USER_PROXY")
56+
5257
# Set up Application Queue
5358
if not (result := self._setUpWorkloadCE(numberOfProcessors))["OK"]:
5459
result["Errno"] = DErrno.ERESUNA
@@ -87,6 +92,8 @@ def execute(self, command, workingDirectory=".", numberOfProcessors=1, cleanRemo
8792
time.sleep(timeBetweenRetries)
8893
else:
8994
result["Errno"] = DErrno.EWMSSUBM
95+
# Restore the original proxy location
96+
os.environ["X509_USER_PROXY"] = originalProxyLocation
9097
return result
9198

9299
jobID = result["Value"][0]
@@ -107,6 +114,8 @@ def execute(self, command, workingDirectory=".", numberOfProcessors=1, cleanRemo
107114
time.sleep(timeBetweenRetries)
108115
else:
109116
result["Errno"] = DErrno.EWMSSTATUS
117+
# Restore the original proxy location
118+
os.environ["X509_USER_PROXY"] = originalProxyLocation
110119
return result
111120

112121
jobStatus = result["Value"][jobID]
@@ -123,6 +132,8 @@ def execute(self, command, workingDirectory=".", numberOfProcessors=1, cleanRemo
123132
time.sleep(timeBetweenRetries)
124133
else:
125134
result["Errno"] = DErrno.EWMSJMAN
135+
# Restore the original proxy location
136+
os.environ["X509_USER_PROXY"] = originalProxyLocation
126137
return result
127138

128139
output, error = result["Value"]
@@ -131,6 +142,8 @@ def execute(self, command, workingDirectory=".", numberOfProcessors=1, cleanRemo
131142
self.log.info("Checking the integrity of the outputs...")
132143
if not (result := self._checkOutputIntegrity("."))["OK"]:
133144
result["Errno"] = DErrno.EWMSJMAN
145+
# Restore the original proxy location
146+
os.environ["X509_USER_PROXY"] = originalProxyLocation
134147
return result
135148
self.log.info("The output has been retrieved and declared complete")
136149

@@ -146,6 +159,9 @@ def execute(self, command, workingDirectory=".", numberOfProcessors=1, cleanRemo
146159
self.log.warn("Failed to clean the output remotely", result["Message"])
147160
self.log.info("The job has been remotely removed")
148161

162+
# Restore the original proxy location
163+
os.environ["X509_USER_PROXY"] = originalProxyLocation
164+
149165
commandStatus = {"Done": 0, "Failed": -1, "Killed": -2}
150166
return S_OK((commandStatus[jobStatus], output, error))
151167

0 commit comments

Comments
 (0)