PBS API show running task as erroneous

arukashi

Member
Jan 21, 2023
12
12
8
Hello!
The topic says it by itself. I have configured monitoring for failed task via API, and i got a little confused with results i got. It is not a big issue, anyway, because template is checking for an endtime value.
Here are responses with different filters

Here is everything totally OK, as i expected, two running tasks, total is 2
Code:
curl -k -X GET 'https://PBS:8007/api2/json/nodes/0/tasks?running=true' -H 'Authorization: PBSAPIToken=xxxxxxxxx' | jq
{
"total": 2,
"data": [
{
"upid": "UPID:PBS:00000278:000003BA:00000322:67DBA0D0:syncjob",
"node": "localhost",
"pid": 632,
"pstart": 954,
"starttime": 1742446800,
"worker_type": "syncjob",
"worker_id": "xxx:xxx:xxx:pve-htznr-5:s-6077bf49-51d4",
"user": "root@pam"
},
{
"upid": "UPID:PBS:00000278:000003BA:0000031E:67DB92C0:syncjob",
"node": "localhost",
"pid": 632,
"pstart": 954,
"starttime": 1742443200,
"worker_type": "syncjob",
"worker_id": "xxx:xxx:xxx:xxx:s-1201e66e-98ff",
"user": "root@pam"
}
]
}

Strange things start here. Same two running task and indeed task that has been finished with an error. And total is 4 somehow
Code:
curl -k -X GET 'https://PBS:8007/api2/json/nodes/0/tasks?typefilter=syncjob&errors=true&limit=3' -H 'Authorization: PBSAPIToken=xxxxxxxxx' | jq
{
"total": 4,
"data": [
{
"upid": "UPID:PBS:00000278:000003BA:00000322:67DBA0D0:syncjob:",
"node": "localhost",
"pid": 632,
"pstart": 954,
"starttime": 1742446800,
"worker_type": "syncjob",
"worker_id": "xxx:xxx:xxx:xxx:s-6077bf49-51d4",
"user": "root@pam"
},
{
"upid": "UPID:PBS:00000278:000003BA:0000031E:67DB92C0:syncjob",
"node": "localhost",
"pid": 632,
"pstart": 954,
"starttime": 1742443200,
"worker_type": "syncjob",
"worker_id": "xxx:xxx:xxx:xxx:s-1201e66e-98ff",
"user": "root@pam"
},
{
"upid": "UPID:PBS:00000278:000003BA:000001F8:67BDC51B:syncjob",
"node": "localhost",
"pid": 632,
"pstart": 954,
"starttime": 1740490011,
"worker_type": "syncjob",
"worker_id": "xxx:xxx:xxx:xxx:s-6077bf49-51d4",
"user": "root@pam",
"endtime": 1740490012,
"status": "sync aborted"
}
]
}

Well, lets specifically exclude running tasks, but... Nope, same two running tasks and different erroneous task. Total is 4 again
Code:
curl -k -X GET 'https://PBS:8007/api2/json/nodes/0/tasks?running=false&errors=true&limit=3' -H 'Authorization: PBSAPIToken=xxxxxxxxx' | jq
{
"total": 4,
"data": [
{
"upid": "UPID:PBS:00000278:000003BA:00000322:67DBA0D0:syncjob",
"node": "localhost",
"pid": 632,
"pstart": 954,
"starttime": 1742446800,
"worker_type": "syncjob",
"worker_id": "xxx:xxx:xxx:xxx:s-6077bf49-51d4",
"user": "root@pam"
},
{
"upid": "UPID:PBS:00000278:000003BA:0000031E:67DB92C0:syncjob",
"node": "localhost",
"pid": 632,
"pstart": 954,
"starttime": 1742443200,
"worker_type": "syncjob",
"worker_id": "xxx:xxx:xxx:xxx:s-1201e66e-98ff",
"user": "root@pam"
},
{
"upid": "UPID:PBS:00182027:23BA733D:00000000:67DB5E78:aptupdate::root@pam:",
"node": "localhost",
"pid": 1581095,
"pstart": 599421757,
"starttime": 1742429816,
"worker_type": "aptupdate",
"worker_id": null,
"user": "root@pam",
"endtime": 1742429816,
"status": "unknown"
}
]
}

For some reason running tasks always end up in errors=true filter. Is this a bug?
Thank you
 
yeah, that is not really intuitive. "running" means "only include running" (so setting it to false just means "include running and not running tasks", not "only include finished tasks"). "errors" means "only include tasks with a failure" (so setting it to false just means "include tasks with and without errors"). but the combination is not additive (setting running and errors doesn't mean "only return running tasks with errors", but "return tasks which are running *or* have errors").

back to your original question - the filtering with "errors" actually works by checking the task state (it skips those with tasks state OK) - guess what running tasks don't have yet? I think it would make sense to treat running tasks as "can't yet have an error" for the purpose of filtering there.. would you mind filing a bug?

the total seems to be off as well (related to pagination, will have to take a closer look).