#4007 Command/API to find previous build logs of a given task
Closed: Fixed by tdecacqu. Opened by tdecacqu.

Hello,

to investigate buildArch failures I would like to get the last successful build logs of a given package.
For example, given this url: https://koji.fedoraproject.org/koji/taskinfo?taskID=112979475 , how can I get the package/arch/tag and how to find its last builds?

Problem 1: how to get the package id for this task?

I tried getting the build id with:

$ curl -X POST https://koji.fedoraproject.org/kojihub -d "<?xml version='1.0'?><methodCall><methodName>findBuildID</methodName><param><value><int>112979475</int></value></param></methodCall>" 
<?xml version='1.0'?><methodResponse><params><param>
  <value><int>112979475</int></value>
</param></params></methodResponse>

But that does not seems valid according to:

$ curl -X POST https://koji.fedoraproject.org/kojihub -d "<?xml version='1.0'?><methodCall><methodName>getBuildLogs</methodName><param><value><int>112979475</int></value></param></methodCall>" 
<?xml version='1.0'?><methodResponse><fault><value><struct><member>
  <name>faultCode</name>
  <value><int>1000</int></value>
</member><member>
  <name>faultString</name>
  <value><string>No such build: 112979475</string></value>
</member></struct></value></fault></methodResponse>

Problem 2: How to get the other builds of a given package/arch/tag?
I could only find the search method, but that seems finicky because it relies on glob, e.g.:

$ curl -X POST https://koji.fedoraproject.org/kojihub -d "<?xml version='1.0'?><methodCall><methodName>search</methodName><params><param><value><string>mingw-qt6-qt5compat-*fc40</string></value></param><param><value><string>build</string></value></param><param><value><string>glob</string></value></param></params></methodCall>" 

Is there a reason you are using curl instead of the koji client?

112979475 is a task id, not a build id.

The koji download-logs command can handle both task ids or a build ids depending on the parameters. If you're curious about the underlying api calls, you can look at the code, or run it with --debug-xmlrpc.

Tasks are not builds, though they sometimes are linked to builds if they create one. This particular task is not. Its parent build task likely was linked to a build at one point, but because it failed and was resubmitted another task is referenced by the build instead.

This appears to be the build in question
https://koji.fedoraproject.org/koji/buildinfo?buildID=2398878

I found this by searching for the nvr.

Metadata Update from @mikem:
- Custom field Size adjusted to None

I am using curl to better understand what data is available, my goal is to automate the process to go from a koji task or build url, as provided by the user, to a list of build logs for the current failure and the logs from the last success.

Presently, with https://koji.fedoraproject.org/koji/taskinfo?taskID=112979475 , I am not able to find the build_id or the nvr of the package.

It's easier to explore the api with the koji call command. Raw xmlrpc is pretty unreadable.

with https://koji.fedoraproject.org/koji/taskinfo?taskID=112979475 , I am not able to find the build_id or the nvr of the package.

First off, you're looking a child task of the main build task, which is this one (follow the parent link).
https://koji.fedoraproject.org/koji/taskinfo?taskID=112979328

That said, this task doesn't have a build_id. Technically, no task actually does. It works the other way around. Builds that were produced by tasks have a task_id. You can find any builds produced by a task with a call like listBuilds(taskID=task_id). For rpm builds, you'll need the task id of the build task; the buildArch task will never be directly associated with a build.

The task that you are looking at does not have a build, because it did not produce one.

$ koji -p fedora call listBuilds taskID=112979328
[]

@mikem thank you for following up on that.

So if I understand correctly, when a task fails (like 112979475), it is not registered as a build in koji? Ok that's fine, I can scrap the build logs manually. But I am still looking for a workflow to go from such a task (the failed one that the user is trying to debug), to the package nvr so that I can reliably find the previous builds for this package.

So looking at the parent task (112979328), how can I get the package nvr? Using the taskinfo method, I only get the source git.

Unfortunately, going from an arbitrary failed build task to "last successful build", is going to involve some heuristic and deduction. The only data you're really guaranteed to have are the task parameters.

I would suggest:

  1. look at the build task parameters and its children to see if you can determine a package name. This will be a somewhat messy heuristic.
  2. get the build target from the build task parameters
  3. query for the latest build for that package in the destination tag of the build target

I.e. in your case:
https://koji.fedoraproject.org/koji/taskinfo?taskID=112979475
Based on parameters, the package name seems to be mingw-qt6-qt5compat
The build target is f40-build-side-82931, which is a now-deleted side-tag.
It's a little tricky to query deleted tags, but had you queried right at failure, you would have seen:

$ koji list-tagged f40-build-side-82931 mingw-qt6-qt5compat --repo=5797312 --inherit --latest
Querying at event 125425672 (Mon Feb  5 10:01:07 2024)
Build                                     Tag                   Built by
----------------------------------------  --------------------  ----------------
mingw-qt6-qt5compat-6.6.1-3.fc40          f40                   releng

So looking at the parent task (112979328), how can I get the package nvr? Using the taskinfo method, I only get the source git.

Unfortunately, NVR (and even N) is technically determined by the build process. So, we only have heuristics.

From the scm url, you can probably at least parse the package name fairly reliably. Technically, the source could be altered to produce a different name, but sane Fedora packages should not.

If the build got far enough along, you could determine the NVR from the results of subtasks. Either the buildSRPMFromSCM or rebuildSRPM subtask (depending on task parameters) should report a source rpm name. This should match the eventual NVR. Of course, a task could fail before this point.

Alright, thank you very much again for explaining all these details. It's a bit unfortunate that this process is not straightforward, but I think I know how to it now.

I am closing this, but feel free to re-open if there is something else that could be done.

Metadata Update from @tdecacqu:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

If you started from failed build entries, the process would be easier

This issue has been migrated to Fedora Forge:
https://forge.fedoraproject.org/koji/koji/issues/4007

Please continue any further discussion there.

Metadata