Skip to content

Commit 69010d1

Browse files
committed
fix: get job parameters the right way in StalledJobAgent
1 parent 4e15998 commit 69010d1

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/DIRAC/WorkloadManagementSystem/Agent/StalledJobAgent.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ def _getJobPilotStatus(self, jobID):
293293
result = getJobParameters([jobID], "Pilot_Reference")
294294
if not result["OK"]:
295295
return result
296-
pilotReference = result["Value"].get("Pilot_Reference")
296+
# getJobParameters returns {jobID: {parName: value, ...}, ...}, with jobID being either an int (JobDB)
297+
# or a str (JobParametersDB), so look it up both ways
298+
jobParameters = result["Value"].get(jobID) or result["Value"].get(str(jobID)) or {}
299+
pilotReference = jobParameters.get("Pilot_Reference")
297300
if not pilotReference:
298301
# There is no pilot reference, hence its status is unknown
299302
return S_OK("NoPilot")
@@ -426,14 +429,17 @@ def _sendAccounting(self, jobID):
426429
endTime = lastHeartBeatTime
427430

428431
result = getJobParameters([jobID], "CPUNormalizationFactor")
429-
if not result["OK"] or not result["Value"] or not result["Value"].get("CPUNormalizationFactor"):
430-
self.log.error(
431-
"Error getting Job Parameter CPUNormalizationFactor, setting 0",
432-
result.get("Message"),
432+
# getJobParameters returns {jobID: {parName: value, ...}, ...}, with jobID being either an int (JobDB)
433+
# or a str (JobParametersDB), so look it up both ways
434+
jobParameters = result.get("Value", {}).get(jobID) or result.get("Value", {}).get(str(jobID)) or {}
435+
if not result["OK"] or not jobParameters.get("CPUNormalizationFactor"):
436+
errorMsg = f"- {result['Message']}" if "Message" in result else "empty"
437+
self.log.warn(
438+
"Error getting Job Parameter CPUNormalizationFactor for", f"{jobID}: setting 0 - {errorMsg}"
433439
)
434440
cpuNormalization = 0.0
435441
else:
436-
cpuNormalization = float(result["Value"].get("CPUNormalizationFactor"))
442+
cpuNormalization = float(jobParameters.get("CPUNormalizationFactor"))
437443

438444
except Exception as e:
439445
self.log.exception(

0 commit comments

Comments
 (0)