Repository navigation
Show why a job failed when it never uploaded its own report - #114921
alexey-milovidov merged 3 commits into
Conversation
Two jobs on ClickHouse#113382 lost their runner mid-Run and both report pages render nothing, so the failure looks like a 0-second job with no output. praktika did detect the failure and did record the reason, but two defects hide it, and either one alone is enough to blank the page. _finish_workflow reported a job that never finalized only through env.add_workflow_error(..., source=result.name). The source= argument sets the "from" label, not the destination, so the message went to the workflow node while the job's own node kept an empty info. The report page renders notifications from the node it resolved, which is the job, so it had nothing to show. The other Status.ERROR sites in runner.py already call add_error on the job's own result; this site did not. A job uploads its own result_<job>.json from inside the job, so a job that dies never uploads one and S3 answers 403. The page turned that 403 into "Report does not exist or expired" and returned, discarding the workflow report it had already fetched, which does contain the job's node. The 403 check for the workflow report itself is left alone: if that one is gone, the report really is gone. The runner loss itself is not fixable here and this does not try to. Only the reporting is changed. Validated with a script that extracts fetchJson, runtimeCache, getTargetResults and fetchData from json.html and replays the measured S3 responses. Pre-fix the page bails; with only the native_jobs.py change it still bails; with only the json.html change it shows the job with no reason; with both it shows the message. The healthy path and the genuinely-expired path are byte-identical to before. The new test in ci/tests/test_result.py fails with KeyError: 'errors' if Result.add_error is neutered, so it is a live check rather than a restatement. runner.py:675 records an artifact-upload failure the same way, but it runs in-job, so its report is uploaded and its page is not blank. Left out to keep this to one root cause. Related: ClickHouse#113382 Co-Authored-By: Claude Opus <[email protected]>
… path Review round 1 on the same change. Two corrections, no redesign. The per-job report cache was only written when the fetch was not a 403, so a 403 left the previous commit's node in it. getTargetResults prefers that cached node, so a page polling sha=latest would show an older run's status and info as if it were the current commit's, with no notification panel. That is worse than the dead end it replaced. fetchJson already returns a null payload on a 403, so restoring the plain "if (updated)" guard both keeps the 403 non-fatal and clears the stale entry. The 403 check for the workflow report is still untouched. The regression test called Result.add_error and Result.from_dict directly. Both are unchanged here, so the test passed on an unpatched tree and could not fail for the reason the change exists. It now drives _finish_workflow itself and asserts on the JSON that Result.dump wrote, which is the file the uploader ships, so it also covers the annotation reaching the report rather than only the in-memory object. It fails with KeyError: 'errors' when the added line is deleted, and on a pristine tree at the merge base with only the test dropped in. The comment on the native_jobs.py call is dropped; it described the fix rather than the code. The json.html comment now states what the line does. Related: ClickHouse#113382 Co-Authored-By: Claude Opus <[email protected]>
Internal second-model review (2 rounds, 2 blockers/majors fixed before publishing)Two review rounds against this change. Round 1 found and fixed one blocker and one major; Round 1❌ blocker: a per-job 403 left a previous commit's job node cached. The first draft made ❌ major: the regression test did not exercise the changed line. The first test called 💡 nit: dropped a comment that only made sense if you already knew what defect this fixes. Round 2Clean, no findings. Checked independently: the workflow report is reloaded from S3 each Scope deliberately left alone: the runner loss itself is not fixable here, and |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-8:20260815-014200 |
|
Workflow [PR], commit [ca59bcb] Summary: ✅ AI ReviewSummaryThis PR fixes Praktika report handling for jobs that die before uploading Final Verdict✅ No findings. |
|
cc @leshikus, could you review this? When a runner dies mid- |
Making a missing result_<job>.json render the workflow-report node left the auto-reload predicate looking at runtimeCache.json1, which stays null on that path. A dead-runner job page therefore rendered a terminal ERROR node and kept refetching S3 every 30 seconds with nothing left to observe. The predicate now reads the node the page actually renders, which is what getTargetResults resolves: json1 when the per-job report exists, otherwise the matching child of the workflow report. Healthy pages short-circuit on json1 and are unaffected, and an unresolved target still keeps polling so a cold or partially-loaded cache is not mistaken for a finished job. Measured with the render-layer replay harness over five S3 states, driving the fetchData/getTargetResults/runtimeCache units and the predicate extracted verbatim from json.html. Only the dead-runner row changes: it settles on the first tick instead of polling forever. Reverting just the predicate restores the old behaviour, and the other four states are byte-identical to master.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units6 translation units recompiled, 5 s compile time in total, 6 of them have a recent master baseline. |
CI finish ledger - ca59bcbCI has fully finished on this head and there are no failures. The praktika report is
Session id: cron:our-pr-ci-monitor:20260815-060000 |
On PR ClickHouse#90117 head cbac4ce, Config Workflow errored and 174 jobs were DROPPED, so nothing ran on that head. The report shows a JSONDecodeError from get_pr_title_body_labels. That is not the cause: it is handled at gh.py:911-921, which prints "Failed to get PR data", stores the traceback and returns ("", "", []), after which native_jobs.py:600-614 guards on "if title:". The job then ran for another 62 seconds and died at native_jobs.py:635 with "Failed to set both GH commit status and PR comment with Workflow Status, cannot proceed", after GitHub answered HTTP 503 to a PATCH of the report comment and a POST of the commit status. That fatal exception never reached the report. Info.store_traceback appends handled tracebacks to env.TRACEBACKS, and Runner._post_run renders those as the job's info. The __main__ handler here is the only frame holding the fatal traceback, and it built its Result with the info= argument commented out on the stated assumption that runner._run() generates info for every job. It does not for this class of job: the log-tail fallback at runner.py:505-521 is gated on "not result.is_completed()", and is_completed() is "status not in (PENDING, RUNNING)", so an ERROR result is already completed and skips it. A native job that dies by exception therefore reports whichever handled traceback happened to be stored earlier, or nothing at all. The traceback is truncated because an exception message can carry command output of any size: gh.py:170-181 raises a RuntimeError whose message interpolates the command, exit code, stderr and stdout with no cap, and that is the retry-exhaustion path a GitHub outage takes. gh.py:271 and gh.py:504 do elide their fields; that one does not. Truncation keeps the tail, because for an ordinary short message that is where the type and the message are. Those same uncapped multi-line messages invert that: format_exc emits the "Type: message" line ahead of the remaining message lines, so once the message exceeds the line budget the surviving window starts past it and the report becomes an unlabelled excerpt of command output. The type and the first message line are therefore kept ahead of the truncated traceback. That shape is reachable from inside the region this handler wraps: native_jobs.py:693 calls _check_db outside any try, which reads a secret through Shell.get_output(strict=True) and raises from utils.py:193-195 with raw multi-line stderr interpolated and no cap. set_info appends, and the handler dumps before _post_run re-reads and appends TRACEBACKS, so the fatal traceback lands first and no existing text is lost. Breadth: 24 PRs took a Config Workflow error on 2026-08-17, 12 of them at this line. I fetched the reports for 8 of the 12 and none showed the fatal error: 5 show the misleading JSONDecodeError and 3 show a completely empty info. Each dropped 174 jobs. One of the 12 reached the same line with no 503 at all, its gh calls exiting 4 for a missing GH_TOKEN, so this reports whatever the cause was rather than assuming a 5xx. Only the reporting is changed. The retry budget is untouched, and so is the "res1 or res2" predicate at the fatal site: whether losing the commit status is survivable when the report comment landed is a design question I am not deciding here. native_jobs.py:747 loses a reason in the same family, assigning the return value of traceback.print_exc() so that sub-result's info is the literal "None". Left out to keep this to one root cause. The new test drives the real __main__ block through runpy with only mangle._get_workflows replaced by a raiser, and asserts against the Result the job dumps to disk. The ordering case additionally runs Runner._post_run, so the append of env.TRACEBACKS is executed rather than modelled: every remote-facing step of _post_run is opt-in per workflow, so a bare Workflow.Config reaches it with no network. All three cases fail on the current code, and each half of the change has its own live oracle: removing only the identifying prefix reddens the bound test alone, and deleting only the append at runner.py:787-788 reddens the ordering test alone. Two tests were dropped along the way for measuring the harness rather than the product. One asserted the pre-fix empty info but passed with the change neutered. The other was an earlier ordering test that called set_info itself instead of running _post_run, so it stayed green with that append deleted. The handler is shared, so _finish_workflow, the docker build jobs and the "BUG, job name" branch are covered too. Jobs that die without raising are already handled by ClickHouse#114921 and are not touched. Regular ci/jobs scripts are unaffected: the runner dumps a RUNNING result before a job, so one that dies leaves is_completed() false and runner.py:511 does fire for it. That asymmetry is the defect. Related: ClickHouse#90117 Co-Authored-By: Claude Opus <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not user-facing: CI report only.
Description
Two jobs on #113382 lost their runner mid-
Run, and both report pages render nothing, sothe failure looks like a 0-second job with no output:
praktika did detect the failure and record the reason, but three defects hide it.
_finish_workflowreported such a job only throughenv.add_workflow_error(..., source=result.name).source=sets thefromlabel, not thedestination, so the message landed on the workflow node while the job's own node kept an
empty
info, and the page renders notifications from the node it resolved, which is thejob. The
Status.ERRORsites inrunner.pyalready calladd_erroron the job's ownresult; this site did not.
A job uploads its own
result_<job>.jsonfrom inside the job, so a job that dies neveruploads one and S3 answers 403. The page turned that 403 into "Report does not exist or
expired" and returned, discarding the workflow report it had already fetched, which does
contain the job's node. That early return is gone, and the cached per-job report is now
overwritten on every fetch that came back, so a page polling
sha=latestcannot keepshowing an older commit's node.
Rendering that node exposed a third defect, already on master: the auto-reload predicate
asked whether the per-job report was running, so a null one read as still loading and the
page refetched S3 every 30 seconds forever. It now asks the node the page actually renders.
The runner loss is not fixable here and this does not try to.
A test drives
_finish_workflowagainst a stubbed environment and asserts the reason reachesthe uploaded workflow report. For the page, a script extracts the relevant functions from
json.htmland replays the measured S3 responses. Reverting any one fix alone reintroducesits symptom; the healthy and expired paths stay byte-identical.