28
28
- setJobParameter()
29
29
- deleteJobParameters()
30
30
"""
31
+ import hashlib
32
+
31
33
from DIRAC import S_OK , gConfig
32
34
from DIRAC .ConfigurationSystem .Client .PathFinder import getDatabaseSection
33
35
from DIRAC .ConfigurationSystem .Client .Helpers import CSGlobals
@@ -125,7 +127,11 @@ def setJobParameter(self, jobID, key, value):
125
127
126
128
self .log .debug ("Inserting data in %s:%s" % (self .indexName , data ))
127
129
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 )
129
135
if not result ["OK" ]:
130
136
self .log .error ("ERROR: Couldn't insert data" , result ["Message" ])
131
137
return result
@@ -142,10 +148,12 @@ def setJobParameters(self, jobID, parameters):
142
148
"""
143
149
self .log .debug ("Inserting parameters" , "in %s: for job %s : %s" % (self .indexName , jobID , parameters ))
144
150
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 })
149
157
150
158
result = self .bulk_index (self .indexName , data = parametersListDict , period = None , withTimeStamp = False )
151
159
if not result ["OK" ]:
0 commit comments