mcp: add log and per-artifact issue query tools - #306
Conversation
| content = response.content | ||
| if content[:2] == b"\x1f\x8b": | ||
| try: | ||
| content = gzip.decompress(content) |
There was a problem hiding this comment.
The download and decompression are not memory-bounded
A large log could exhaust the MCP process’s memory.
This should use streaming decompression with a bounded head/tail buffer and a hard size limit.
|
The trust boundary around log_url should be clarified. The code performs a direct GET, including redirects, against a URL obtained from dashboard data. If external submitters can control that field, this creates risk. The implementation should validate schemes, private/link-local addresses, DNS results, and redirect targets or document why all returned URLs are trusted. |
|
The happy paths have pytest coverage, but the security- and boundary-sensitive behavior is not covered. Please add tests for zero/negative/oversized max_bytes, truncated or malformed gzip input, download failures, bounded streaming/decompression, and URL/redirect validation. These tests should accompany the corresponding implementation fixes before approval. |
9001297 to
5700d3b
Compare
Good point, now becomes a KciDevError I also fixed multi-member gzip, which previously dropped everything after the first member. To your first comment r.e. log_url, I added a fetch-time guard that allows only http/https. Which also resolves the host and rejects private/loopback/link-local/reserved addresses (and follows redirects). Also have added tests. Thanks for the feedback @aliceinwire. Sorry would done it quicker (was on holiday but back now) |
dd446ee to
9ff6eca
Compare
|
Hi @bhcopeland , I tested 3 scenario, but infra failure log need some work. other interface works fine, next I will test including kci-dev as lib to my https://github.com/yogeshlal/triage-agent.
Pulled the full log for maestro:6a90aec3c5867fba94687850 (106,313 bytes, in three get_log slices — head, tail, and the middle — so the whole file is covered). Job: LAVA job 217635, device qcs615-ride-ch-kci-02 (QCS615 Ride / IQ-615 Beta EVK), baseline-arm64-preempt_rt-qualcomm The one real kernel defect: a boot-time WARNING in the tracepoint self-check Fires at [0.000000], during trace_init() — before anything else runs: TRACE EVENT ERROR: Event mtu3_gadget_ep_set_halt has double dereference in TP_printk: &REC->gpd_ring->dma Two more of the same class follow (no second splat, warn-once):
Root cause is in the tracepoint definitions, not on this platform: the MediaTek mtu3 USB gadget tracepoints (drivers/usb/mtu3/mtu3_trace.h) format &REC->gpd_ring->dma, Everything else is missing-firmware noise from the rootfs, not kernel failure
Pulled the log for maestro:6a90b649c5867fba9468bab3 (tail + head; 115,639 bytes total, kselftest-ring-buffer-ramdisk, device kaanapali-mdt-kci-0801). Verdict: harness/rootfs failure, not a kernel regression The single reported result is a harness-level marker, not a ring-buffer test case:
shardfile-ring-buffer is the ID kselftest.sh emits when it cannot produce/read a shard list for the requested collection. Zero ring-buffer subtests ran — no ok/not ok,
┌──────────────────────────────────┬───────────────────────────────────────────────┐ get_log only resolves test/boot nodes via the dashboard's test endpoint. A "Test not found" for both forms means that id isn't a test node the dashboard has ingested — You restricted me to get_log, so I stopped here rather than probing get_build/list_tests. Say the word and I'll try get_build maestro:6a90b63cc5867fba9468b9b1 — that's |
Add three read-only dashboard tools, exposed both as MCP tools and on KernelCIClient: - get_log resolves a test's log from log_url, or a log entry in output_files when log_url is empty (as it is for many failures), and returns the decompressed text bounded to the tail by default with total_bytes and a truncated flag. The download streams with a bounded head/tail buffer, decompresses gzip incrementally, caps max_bytes at a hard ceiling, stops after a scan limit to bound memory, and validates the URL scheme and resolved address (rejecting private/link-local hosts and unvalidated redirects) since log URLs come from submitter data - get_test_issues / get_build_issues list the issues tracked for a specific test or build, the inverse of the existing get_issue_tests and get_issue_builds get_log is new on KernelCIClient; the issue tools expose existing client methods that were not yet surfaced in the MCP. The request timeout is per read rather than total, and the scan limit is 64 MiB read in 64 KiB chunks, so a slow server could hold the caller for far longer than any single timeout suggests. Reading also stops at a total deadline, reported as deadline_exceeded, which matters now that tool calls run in worker threads and a stalled download occupies one. The dashboard reports an artifact with no known issues as an error rather than an empty list, so the two issue tools return that as an empty list. "Nothing is tracked against this build" is the answer a caller checking a failure wants, not a failed call. The CLI already treats the same response that way at its own call sites. Signed-off-by: Ben Copeland <ben.copeland@linaro.org>
9ff6eca to
14c9675
Compare
|
Thanks @yogeshlal for the report, very useful :) Looking at your data, that's an incomplete job: kind=job, result=incomplete. It never reaches the dashboard, because the dashboard ingests test and build results, not failed jobs. It's not a build node either, so get_build will give you the same "not found". The good news is you don't need get_log for this one. get_node on that id returns it already: So the diagnosis is right there, plus a link to the raw LAVA callback if you want it. That should unblock the triage agent work you are doing. For wiring it in properly, I'd either have get_log fall back to Maestro when the dashboard has no test, or add a separate tool for job-level failures. The first feels friendlier for agents (one tool, works for any id). Either way it's a gap rather than a bug in this PR, so I'd suggest doing it separately. |
Add three read-only dashboard tools, exposed both as MCP tools and on KernelCIClient:
get_log is new on KernelCIClient; the issue tools expose existing client methods that were not yet surfaced in the MCP.