Skip to content

Commit 191ea07

Browse files
committed
sweep: #5979 fix: StalledJobAgent can force status from Submitting to Failed
1 parent efe4d1f commit 191ea07

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/StalledJobAgent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def _failSubmittingJobs(self):
562562
return result
563563

564564
for jobID in result["Value"]:
565-
result = self._updateJobStatus(jobID, JobStatus.FAILED)
565+
result = self._updateJobStatus(jobID, JobStatus.FAILED, force=True)
566566
if not result["OK"]:
567567
self.log.error("Failed to update job status", result["Message"])
568568
continue

src/DIRAC/WorkloadManagementSystem/DB/ElasticJobParametersDB.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
- setJobParameter()
2929
- deleteJobParameters()
3030
"""
31+
import hashlib
32+
3133
from DIRAC import S_OK, gConfig
3234
from DIRAC.ConfigurationSystem.Client.PathFinder import getDatabaseSection
3335
from DIRAC.ConfigurationSystem.Client.Helpers import CSGlobals
@@ -125,7 +127,11 @@ def setJobParameter(self, jobID, key, value):
125127

126128
self.log.debug("Inserting data in %s:%s" % (self.indexName, data))
127129

128-
result = self.index(self.indexName, body=data, docID=str(jobID) + key)
130+
# The _id in ES can't exceed 512 bytes, this is a ES hard-coded limitation.
131+
docID = str(jobID) + key
132+
if len(docID) > 505:
133+
docID = docID[:475] + hashlib.md5(docID.encode()).hexdigest()[:35]
134+
result = self.index(self.indexName, body=data, docID=docID)
129135
if not result["OK"]:
130136
self.log.error("ERROR: Couldn't insert data", result["Message"])
131137
return result
@@ -142,10 +148,12 @@ def setJobParameters(self, jobID, parameters):
142148
"""
143149
self.log.debug("Inserting parameters", "in %s: for job %s : %s" % (self.indexName, jobID, parameters))
144150

145-
parametersListDict = [
146-
{"JobID": jobID, "Name": parName, "Value": parValue, "_id": str(jobID) + str(parName) + str(parValue)}
147-
for parName, parValue in parameters
148-
]
151+
parametersListDict = []
152+
for parName, parValue in parameters:
153+
docID = str(jobID) + parName
154+
if len(docID) > 505:
155+
docID = docID[:475] + hashlib.md5(docID.encode()).hexdigest()[:35]
156+
parametersListDict.append({"JobID": jobID, "Name": parName, "Value": parValue, "_id": docID})
149157

150158
result = self.bulk_index(self.indexName, data=parametersListDict, period=None, withTimeStamp=False)
151159
if not result["OK"]:

0 commit comments

Comments
 (0)