Skip to content

Commit

Permalink
fix: prevent corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Nov 8, 2024
1 parent d221130 commit 6dc37a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/DIRAC/WorkloadManagementSystem/DB/JobDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ def setJobAttribute(self, jobID, attrName, attrValue, update=False, myDate=None,
:return: S_OK/S_ERROR
"""

if not jobID:
return S_OK()

if attrName not in self.jobAttributeNames:
return S_ERROR(EWMSJMAN, "Request to set non-existing job attribute")

Expand Down Expand Up @@ -505,6 +508,9 @@ def setJobAttributes(self, jobID, attrNames, attrValues, update=False, myDate=No
:return: S_OK/S_ERROR
"""

if not jobID:
return S_OK()

jobIDList = jobID
if not isinstance(jobID, (list, tuple)):
jobIDList = [jobID]
Expand Down
16 changes: 8 additions & 8 deletions src/DIRAC/WorkloadManagementSystem/DB/JobLoggingDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ def _get_date(date):

# if JobID is a list, make a bulk insert
if isinstance(jobID, list):
for i, _ in enumerate(jobID):
epoc = _date[i].replace(tzinfo=datetime.timezone.utc).timestamp() - MAGIC_EPOC_NUMBER
cmd = cmd + "(%d,'%s','%s','%s','%s',%f,'%s')," % (
int(jobID[i]),
status[i],
minorStatus[i],
applicationStatus[:255],
str(_date[i]),
for jid, stat, mstat, appstat, dt in zip(jobID, status, minorStatus, applicationStatus, _date):
epoc = dt.replace(tzinfo=datetime.timezone.utc).timestamp() - MAGIC_EPOC_NUMBER
cmd += "(%d,'%s','%s','%s','%s',%f,'%s')," % (
int(jid),
stat,
mstat,
appstat[:255],
str(dt),
epoc,
source[:32],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ def export_submitJob(self, jobDesc):
jobIDList, statusList, minorStatusList, date=timeStampList, source="JobManager"
)
else:
for i, _ in enumerate(jobIDList):
for jobID, status, minorStatus, timeStamp in zip(jobIDList, statusList, minorStatusList, timeStampList):
result = self.jobLoggingDB.addLoggingRecord(
jobIDList[i], statusList[i], minorStatusList[i], date=timeStampList[i], source="JobManager"
jobID, status, minorStatus, date=timeStamp, source="JobManager"
)

# Set persistency flag
Expand Down

0 comments on commit 6dc37a4

Please sign in to comment.